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
30873802
Commit
30873802
authored
Apr 10, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Don't set response content-length if HTTP/2 response upgraded
parent
97366bf5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
31 deletions
+29
-31
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+29
-31
No files found.
src/shrpx_http2_session.cc
View file @
30873802
...
...
@@ -838,35 +838,9 @@ int on_response_headers(Http2Session *http2session, Downstream *downstream,
return
0
;
}
auto
content_length
=
downstream
->
get_response_header
(
http2
::
HD_CONTENT_LENGTH
);
if
(
content_length
)
{
// libnghttp2 guarantees this can be parsed
auto
len
=
util
::
parse_uint
(
content_length
->
value
);
downstream
->
set_response_content_length
(
len
);
}
if
(
downstream
->
get_response_content_length
()
==
-
1
&&
downstream
->
expect_response_body
())
{
// Here we have response body but Content-Length is not known in
// advance.
if
(
downstream
->
get_request_major
()
<=
0
||
(
downstream
->
get_request_major
()
<=
1
&&
downstream
->
get_request_minor
()
<=
0
))
{
// We simply close connection for pre-HTTP/1.1 in this case.
downstream
->
set_response_connection_close
(
true
);
}
else
if
(
downstream
->
get_request_method
()
!=
"CONNECT"
)
{
// Otherwise, use chunked encoding to keep upstream connection
// open. In HTTP2, we are supporsed not to receive
// transfer-encoding.
downstream
->
add_response_header
(
"transfer-encoding"
,
"chunked"
,
http2
::
HD_TRANSFER_ENCODING
);
downstream
->
set_chunked_response
(
true
);
}
}
downstream
->
set_response_state
(
Downstream
::
HEADER_COMPLETE
);
downstream
->
check_upgrade_fulfilled
();
if
(
downstream
->
get_upgraded
())
{
downstream
->
set_response_connection_close
(
true
);
// On upgrade sucess, both ends can send data
...
...
@@ -880,11 +854,35 @@ int on_response_headers(Http2Session *http2session, Downstream *downstream,
SSLOG
(
INFO
,
http2session
)
<<
"HTTP upgrade success. stream_id="
<<
frame
->
hd
.
stream_id
;
}
}
else
if
(
downstream
->
get_request_method
()
==
"CONNECT"
)
{
// If request is CONNECT, terminate request body to avoid for
// stream to stall.
downstream
->
end_upload_data
();
}
else
{
auto
content_length
=
downstream
->
get_response_header
(
http2
::
HD_CONTENT_LENGTH
);
if
(
content_length
)
{
// libnghttp2 guarantees this can be parsed
auto
len
=
util
::
parse_uint
(
content_length
->
value
);
downstream
->
set_response_content_length
(
len
);
}
if
(
downstream
->
get_response_content_length
()
==
-
1
&&
downstream
->
expect_response_body
())
{
// Here we have response body but Content-Length is not known in
// advance.
if
(
downstream
->
get_request_major
()
<=
0
||
(
downstream
->
get_request_major
()
==
1
&&
downstream
->
get_request_minor
()
==
0
))
{
// We simply close connection for pre-HTTP/1.1 in this case.
downstream
->
set_response_connection_close
(
true
);
}
else
{
// Otherwise, use chunked encoding to keep upstream connection
// open. In HTTP2, we are supporsed not to receive
// transfer-encoding.
downstream
->
add_response_header
(
"transfer-encoding"
,
"chunked"
,
http2
::
HD_TRANSFER_ENCODING
);
downstream
->
set_chunked_response
(
true
);
}
}
}
rv
=
upstream
->
on_downstream_header_complete
(
downstream
);
if
(
rv
!=
0
)
{
http2session
->
submit_rst_stream
(
frame
->
hd
.
stream_id
,
...
...
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