Commit 2d2b72d4 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

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

parent b39ad313
...@@ -740,7 +740,8 @@ bool Downstream::get_expect_final_response() const { ...@@ -740,7 +740,8 @@ bool Downstream::get_expect_final_response() const {
} }
bool Downstream::expect_response_body() 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 { namespace {
......
...@@ -185,7 +185,8 @@ struct Response { ...@@ -185,7 +185,8 @@ struct Response {
http_status(0), http_status(0),
http_major(1), http_major(1),
http_minor(1), http_minor(1),
connection_close(false) {} connection_close(false),
headers_only(false) {}
void consume(size_t len) { void consume(size_t len) {
assert(unconsumed_body_length >= len); assert(unconsumed_body_length >= len);
...@@ -202,6 +203,10 @@ struct Response { ...@@ -202,6 +203,10 @@ struct Response {
unsigned int http_status; unsigned int http_status;
int http_major, http_minor; int http_major, http_minor;
bool connection_close; 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 { class Downstream {
......
...@@ -1024,6 +1024,10 @@ int on_response_headers(Http2Session *http2session, Downstream *downstream, ...@@ -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); rv = upstream->on_downstream_header_complete(downstream);
if (rv != 0) { if (rv != 0) {
// Handling early return (in other words, response was hijacked by // Handling early return (in other words, response was hijacked by
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment