nghttpx: Set content-length after complete request/response headers
This commit is contained in:
parent
87cadca3d8
commit
97366bf55c
|
@ -757,12 +757,6 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
||||||
|
|
||||||
auto token = http2::lookup_token(name, namelen);
|
auto token = http2::lookup_token(name, namelen);
|
||||||
|
|
||||||
if (token == http2::HD_CONTENT_LENGTH) {
|
|
||||||
// libnghttp2 guarantees this can be parsed
|
|
||||||
auto len = util::parse_uint(value, valuelen);
|
|
||||||
downstream->set_response_content_length(len);
|
|
||||||
}
|
|
||||||
|
|
||||||
downstream->add_response_header(name, namelen, value, valuelen,
|
downstream->add_response_header(name, namelen, value, valuelen,
|
||||||
flags & NGHTTP2_NV_FLAG_NO_INDEX, token);
|
flags & NGHTTP2_NV_FLAG_NO_INDEX, token);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -844,6 +838,14 @@ int on_response_headers(Http2Session *http2session, Downstream *downstream,
|
||||||
return 0;
|
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 &&
|
if (downstream->get_response_content_length() == -1 &&
|
||||||
downstream->expect_response_body()) {
|
downstream->expect_response_body()) {
|
||||||
// Here we have response body but Content-Length is not known in
|
// Here we have response body but Content-Length is not known in
|
||||||
|
|
|
@ -233,12 +233,6 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
||||||
|
|
||||||
auto token = http2::lookup_token(name, namelen);
|
auto token = http2::lookup_token(name, namelen);
|
||||||
|
|
||||||
if (token == http2::HD_CONTENT_LENGTH) {
|
|
||||||
// libnghttp2 guarantees this can be parsed
|
|
||||||
auto len = util::parse_uint(value, valuelen);
|
|
||||||
downstream->set_request_content_length(len);
|
|
||||||
}
|
|
||||||
|
|
||||||
downstream->add_request_header(name, namelen, value, valuelen,
|
downstream->add_request_header(name, namelen, value, valuelen,
|
||||||
flags & NGHTTP2_NV_FLAG_NO_INDEX, token);
|
flags & NGHTTP2_NV_FLAG_NO_INDEX, token);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -300,6 +294,14 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
|
||||||
http2::dump_nv(get_config()->http2_upstream_dump_request_header, nva);
|
http2::dump_nv(get_config()->http2_upstream_dump_request_header, nva);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto content_length =
|
||||||
|
downstream->get_request_header(http2::HD_CONTENT_LENGTH);
|
||||||
|
if (content_length) {
|
||||||
|
// libnghttp2 guarantees this can be parsed
|
||||||
|
auto len = util::parse_uint(content_length->value);
|
||||||
|
downstream->set_request_content_length(len);
|
||||||
|
}
|
||||||
|
|
||||||
auto authority = downstream->get_request_header(http2::HD__AUTHORITY);
|
auto authority = downstream->get_request_header(http2::HD__AUTHORITY);
|
||||||
auto path = downstream->get_request_header(http2::HD__PATH);
|
auto path = downstream->get_request_header(http2::HD__PATH);
|
||||||
auto method = downstream->get_request_header(http2::HD__METHOD);
|
auto method = downstream->get_request_header(http2::HD__METHOD);
|
||||||
|
|
Loading…
Reference in New Issue