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
38788d70
Commit
38788d70
authored
Mar 06, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asio: Don't send response body if it is not expected by status code or method
parent
44c0d32a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
src/asio_server_response_impl.cc
src/asio_server_response_impl.cc
+17
-0
No files found.
src/asio_server_response_impl.cc
View file @
38788d70
...
...
@@ -25,6 +25,7 @@
#include "asio_server_response_impl.h"
#include "asio_server_stream.h"
#include "asio_server_request_impl.h"
#include "asio_server_http2_handler.h"
#include "asio_common.h"
...
...
@@ -78,9 +79,25 @@ void response_impl::end(generator_cb cb) {
state_
=
response_state
::
BODY_STARTED
;
}
namespace
{
bool
expect_response_body
(
const
std
::
string
&
method
,
int
status_code
)
{
return
method
!=
"HEAD"
&&
status_code
/
100
!=
1
&&
status_code
!=
304
&&
status_code
!=
204
;
}
}
// namespace
void
response_impl
::
start_response
()
{
auto
handler
=
strm_
->
handler
();
auto
&
req
=
strm_
->
request
().
impl
();
// if response body is not expected, nullify it so that HEADERS has
// END_STREAM flag set.
if
(
!
expect_response_body
(
req
.
method
(),
status_code_
))
{
state_
=
response_state
::
BODY_STARTED
;
generator_cb_
=
generator_cb
();
}
if
(
handler
->
start_response
(
*
strm_
)
!=
0
)
{
handler
->
stream_error
(
strm_
->
get_stream_id
(),
NGHTTP2_INTERNAL_ERROR
);
return
;
...
...
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