Open const-t opened 3 months ago
It looks we can just skip Content-Length addition for HTTP2 in tfw_http_resp_terminate().
As for addition this header field during http2 message adjusting, we add this field in tfw_h2_resp_encode_headers() only for chunked responses:
if (test_bit(TFW_HTTP_B_CHUNKED, resp->flags)) {
if (unlikely(tfw_h2_add_hdr_clen(resp)))
goto clean;
}
I'm not sure what behavior is desired. RFC 3119 says nothing about content-length usage. It's a completely optional field. This issue looks independent, and we could discuss it separately.
In PR2243 we partly removed Content-length header for HTTP2. In the future we need to remove the rest of the places where this header is added. Also we need to correct tests (look for __prepare_chunked_expected_response function in framework/deproxy_auto_parser.py).
The first part of this task about not optimal behavior was done in PR2243.
https://github.com/tempesta-tech/tempesta/pull/2243 doesn't fully fix the problem
We have some not optimal behavior. In case when
Content-Length
not listed in response headers and upstream server indicates message finishing by closing connection in functiontfw_http_resp_terminate()
we addContent-Length
header. Upd: The first part of this task about not optimal behavior was done in PR2243.But for http2 protocol we call
tfw_h2_msg_cutoff_headers()
and after HPack encode headers, it implies we must not add the header intfw_http_resp_terminate()
but add this header during http2 message adjusting.