nghttpx: Cleanup code where request content-length is involved
This commit is contained in:
parent
631f977236
commit
852a320586
|
@ -426,11 +426,10 @@ int Http2DownstreamConnection::push_request_headers() {
|
||||||
DCLOG(INFO, this) << "HTTP request headers\n" << ss.str();
|
DCLOG(INFO, this) << "HTTP request headers\n" << ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto content_length = req.fs.header(http2::HD_CONTENT_LENGTH);
|
// Add body as long as transfer-encoding is given even if
|
||||||
// TODO check content-length: 0 case
|
// req.fs.content_length == 0 to forward trailer fields.
|
||||||
|
if (req.method == HTTP_CONNECT || transfer_encoding ||
|
||||||
if (req.method == HTTP_CONNECT || chunked_encoding || content_length ||
|
req.fs.content_length > 0 || req.http2_expect_body) {
|
||||||
req.http2_expect_body) {
|
|
||||||
// Request-body is expected.
|
// Request-body is expected.
|
||||||
nghttp2_data_provider data_prd{{}, http2_data_read_callback};
|
nghttp2_data_provider data_prd{{}, http2_data_read_callback};
|
||||||
rv = http2session_->submit_request(this, nva.data(), nva.size(), &data_prd);
|
rv = http2session_->submit_request(this, nva.data(), nva.size(), &data_prd);
|
||||||
|
|
|
@ -373,9 +373,9 @@ int HttpDownstreamConnection::push_request_headers() {
|
||||||
buf->append("\r\n");
|
buf->append("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connect_method && req.http2_expect_body &&
|
// set transfer-encoding only when content-length is unknown and
|
||||||
!req.fs.header(http2::HD_CONTENT_LENGTH)) {
|
// request body is expected.
|
||||||
|
if (!connect_method && req.http2_expect_body && req.fs.content_length == -1) {
|
||||||
downstream_->set_chunked_request(true);
|
downstream_->set_chunked_request(true);
|
||||||
buf->append("Transfer-Encoding: chunked\r\n");
|
buf->append("Transfer-Encoding: chunked\r\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,8 +312,10 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
ULOG(INFO, upstream) << "HTTP request headers\n" << ss.str();
|
ULOG(INFO, upstream) << "HTTP request headers\n" << ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.fs.parse_content_length() != 0) {
|
// set content-length if no transfer-encoding is given. If
|
||||||
return -1;
|
// transfer-encoding is given, leave req.fs.content_length to -1.
|
||||||
|
if (!req.fs.header(http2::HD_TRANSFER_ENCODING)) {
|
||||||
|
req.fs.content_length = htp->content_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto host = req.fs.header(http2::HD_HOST);
|
auto host = req.fs.header(http2::HD_HOST);
|
||||||
|
|
Loading…
Reference in New Issue