Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
5645cad5
Commit
5645cad5
authored
Dec 03, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept and ignore content-length: 0 in 204 response for now
parent
85ba33c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
6 deletions
+34
-6
lib/nghttp2_http.c
lib/nghttp2_http.c
+15
-1
lib/nghttp2_int.h
lib/nghttp2_int.h
+7
-1
tests/nghttp2_session_test.c
tests/nghttp2_session_test.c
+12
-4
No files found.
lib/nghttp2_http.c
View file @
5645cad5
...
...
@@ -250,7 +250,21 @@ static int http_response_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
break
;
}
case
NGHTTP2_TOKEN_CONTENT_LENGTH
:
{
if
(
stream
->
status_code
==
204
||
stream
->
status_code
/
100
==
1
||
if
(
stream
->
status_code
==
204
)
{
/* content-length header field in 204 response is prohibited by
RFC 7230. But some widely used servers send content-length:
0. Until they get fixed, we ignore it. */
if
(
stream
->
content_length
!=
-
1
)
{
/* Found multiple content-length field */
return
NGHTTP2_ERR_HTTP_HEADER
;
}
if
(
!
lstrieq
(
"0"
,
nv
->
value
->
base
,
nv
->
value
->
len
))
{
return
NGHTTP2_ERR_HTTP_HEADER
;
}
stream
->
content_length
=
0
;
return
NGHTTP2_ERR_REMOVE_HTTP_HEADER
;
}
if
(
stream
->
status_code
/
100
==
1
||
(
stream
->
status_code
==
200
&&
(
stream
->
http_flags
&
NGHTTP2_HTTP_FLAG_METH_CONNECT
)))
{
return
NGHTTP2_ERR_HTTP_HEADER
;
...
...
lib/nghttp2_int.h
View file @
5645cad5
...
...
@@ -46,7 +46,13 @@ typedef enum {
* Invalid HTTP header field was received but it can be treated as
* if it was not received because of compatibility reasons.
*/
NGHTTP2_ERR_IGN_HTTP_HEADER
=
-
105
NGHTTP2_ERR_IGN_HTTP_HEADER
=
-
105
,
/*
* Invalid HTTP header field was received, and it is ignored.
* Unlike NGHTTP2_ERR_IGN_HTTP_HEADER, this does not invoke
* nghttp2_on_invalid_header_callback.
*/
NGHTTP2_ERR_REMOVE_HTTP_HEADER
=
-
106
}
nghttp2_internal_error
;
#endif
/* NGHTTP2_INT_H */
tests/nghttp2_session_test.c
View file @
5645cad5
...
...
@@ -10204,6 +10204,8 @@ void test_nghttp2_http_mandatory_headers(void) {
MAKE_NV
(
"content-length"
,
"0"
)};
const
nghttp2_nv
cl204_resnv
[]
=
{
MAKE_NV
(
":status"
,
"204"
),
MAKE_NV
(
"content-length"
,
"0"
)};
const
nghttp2_nv
clnonzero204_resnv
[]
=
{
MAKE_NV
(
":status"
,
"204"
),
MAKE_NV
(
"content-length"
,
"100"
)};
/* test case for request */
const
nghttp2_nv
nopath_reqnv
[]
=
{
MAKE_NV
(
":scheme"
,
"https"
),
...
...
@@ -10307,10 +10309,16 @@ void test_nghttp2_http_mandatory_headers(void) {
NGHTTP2_STREAM_OPENING
,
cl1xx_resnv
,
ARRLEN
(
cl1xx_resnv
));
/* response header has content-length with 204 status code */
check_nghttp2_http_recv_headers_fail
(
session
,
&
deflater
,
19
,
NGHTTP2_STREAM_OPENING
,
cl204_resnv
,
ARRLEN
(
cl204_resnv
));
/* response header has 0 content-length with 204 status code */
check_nghttp2_http_recv_headers_ok
(
session
,
&
deflater
,
19
,
NGHTTP2_STREAM_OPENING
,
cl204_resnv
,
ARRLEN
(
cl204_resnv
));
/* response header has nonzero content-length with 204 status
code */
check_nghttp2_http_recv_headers_fail
(
session
,
&
deflater
,
21
,
NGHTTP2_STREAM_OPENING
,
clnonzero204_resnv
,
ARRLEN
(
clnonzero204_resnv
));
nghttp2_hd_deflate_free
(
&
deflater
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment