Commit 095bc178 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Robust HTTP/1 backend CL and TE handling

We should ignore Content-Length and Transfer-Encoding for upgraded
response, and reset content-length if this is a non-final response.
parent 30873802
...@@ -520,6 +520,9 @@ int htp_hdrs_completecb(http_parser *htp) { ...@@ -520,6 +520,9 @@ int htp_hdrs_completecb(http_parser *htp) {
} }
if (downstream->get_non_final_response()) { if (downstream->get_non_final_response()) {
// Reset content-length because we reuse same Downstream for the
// next response.
downstream->set_response_content_length(-1);
// For non-final response code, we just call // For non-final response code, we just call
// on_downstream_header_complete() without changing response // on_downstream_header_complete() without changing response
// state. // state.
...@@ -537,7 +540,11 @@ int htp_hdrs_completecb(http_parser *htp) { ...@@ -537,7 +540,11 @@ int htp_hdrs_completecb(http_parser *htp) {
downstream->inspect_http1_response(); downstream->inspect_http1_response();
downstream->check_upgrade_fulfilled(); downstream->check_upgrade_fulfilled();
if (downstream->get_upgraded()) { if (downstream->get_upgraded()) {
// content-length must be ignored for upgraded connection.
downstream->set_response_content_length(-1);
downstream->set_response_connection_close(true); downstream->set_response_connection_close(true);
// transfer-encoding not applied to upgraded connection
downstream->set_chunked_response(false);
} }
if (upstream->on_downstream_header_complete(downstream) != 0) { if (upstream->on_downstream_header_complete(downstream) != 0) {
return -1; return -1;
......
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