nghttpx: Always expect response trailer fields
This commit is contained in:
parent
dba0f35ee1
commit
d2f4e4e325
|
@ -744,6 +744,13 @@ bool Downstream::expect_response_body() const {
|
||||||
http2::expect_response_body(req_.method, resp_.http_status);
|
http2::expect_response_body(req_.method, resp_.http_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Downstream::expect_response_trailer() const {
|
||||||
|
// In HTTP/2, if final response HEADERS does not bear END_STREAM it
|
||||||
|
// is possible trailer fields might come, regardless of request
|
||||||
|
// method or status code.
|
||||||
|
return !resp_.headers_only && resp_.http_major == 2;
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void reset_timer(struct ev_loop *loop, ev_timer *w) { ev_timer_again(loop, w); }
|
void reset_timer(struct ev_loop *loop, ev_timer *w) { ev_timer_again(loop, w); }
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -278,6 +278,7 @@ public:
|
||||||
bool validate_request_recv_body_length() const;
|
bool validate_request_recv_body_length() const;
|
||||||
void set_request_downstream_host(const StringRef &host);
|
void set_request_downstream_host(const StringRef &host);
|
||||||
bool expect_response_body() const;
|
bool expect_response_body() const;
|
||||||
|
bool expect_response_trailer() const;
|
||||||
enum {
|
enum {
|
||||||
INITIAL,
|
INITIAL,
|
||||||
HEADER_COMPLETE,
|
HEADER_COMPLETE,
|
||||||
|
|
|
@ -1520,7 +1520,8 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
|
||||||
|
|
||||||
nghttp2_data_provider *data_prdptr;
|
nghttp2_data_provider *data_prdptr;
|
||||||
|
|
||||||
if (downstream->expect_response_body()) {
|
if (downstream->expect_response_body() ||
|
||||||
|
downstream->expect_response_trailer()) {
|
||||||
data_prdptr = &data_prd;
|
data_prdptr = &data_prd;
|
||||||
} else {
|
} else {
|
||||||
data_prdptr = nullptr;
|
data_prdptr = nullptr;
|
||||||
|
|
|
@ -604,6 +604,13 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
resp.http_major = htp->http_major;
|
resp.http_major = htp->http_major;
|
||||||
resp.http_minor = htp->http_minor;
|
resp.http_minor = htp->http_minor;
|
||||||
|
|
||||||
|
if (resp.http_major > 1) {
|
||||||
|
// Normalize HTTP version, since we use http_major == 2 specially
|
||||||
|
// in Downstream::expect_response_trailer().
|
||||||
|
resp.http_major = 1;
|
||||||
|
resp.http_minor = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (resp.fs.parse_content_length() != 0) {
|
if (resp.fs.parse_content_length() != 0) {
|
||||||
downstream->set_response_state(Downstream::MSG_BAD_HEADER);
|
downstream->set_response_state(Downstream::MSG_BAD_HEADER);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue