nghttpx: Don't add 0-length DATA when response HEADERS bears END_STREAM flag

This commit is contained in:
Tatsuhiro Tsujikawa 2016-04-27 21:19:28 +09:00
parent b39ad3135d
commit 2d2b72d4eb
3 changed files with 12 additions and 2 deletions

View File

@ -740,7 +740,8 @@ bool Downstream::get_expect_final_response() const {
}
bool Downstream::expect_response_body() const {
return http2::expect_response_body(req_.method, resp_.http_status);
return !resp_.headers_only &&
http2::expect_response_body(req_.method, resp_.http_status);
}
namespace {

View File

@ -185,7 +185,8 @@ struct Response {
http_status(0),
http_major(1),
http_minor(1),
connection_close(false) {}
connection_close(false),
headers_only(false) {}
void consume(size_t len) {
assert(unconsumed_body_length >= len);
@ -202,6 +203,10 @@ struct Response {
unsigned int http_status;
int http_major, http_minor;
bool connection_close;
// true if response only consists of HEADERS, and it bears
// END_STREAM. This is used to tell Http2Upstream that it can send
// response with single HEADERS with END_STREAM flag only.
bool headers_only;
};
class Downstream {

View File

@ -1024,6 +1024,10 @@ int on_response_headers(Http2Session *http2session, Downstream *downstream,
}
}
if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
resp.headers_only = true;
}
rv = upstream->on_downstream_header_complete(downstream);
if (rv != 0) {
// Handling early return (in other words, response was hijacked by