mirror of
https://github.com/curl/curl.git
synced 2026-08-26 14:43:32 +03:00
http: fix HTTP/2 handling of TE request header using "trailers"
A "TE" request header is allowed in HTTP/2 when it only carries the "trailers" value. RFC 9113 ch. 8.2.2. Check client supplied TE values for the "trailers" token and only pass that one in a HTTP/2 request. Add test_01_17 to verify. Fixes #17122 Reported-by: epicmkirzinger on github Closes #17128
This commit is contained in:
parent
ebe6612505
commit
1d66a769d7
3 changed files with 67 additions and 7 deletions
|
|
@ -258,3 +258,24 @@ class TestBasic:
|
|||
r.check_exit_code(0)
|
||||
else:
|
||||
r.check_exit_code(43)
|
||||
|
||||
# http: special handling of TE request header
|
||||
@pytest.mark.parametrize("te_in, te_out", [
|
||||
['trailers', 'trailers'],
|
||||
['chunked', None],
|
||||
['gzip, trailers', 'trailers'],
|
||||
['gzip ;q=0.2;x="y,x", trailers', 'trailers'],
|
||||
['gzip ;x="trailers", chunks', None],
|
||||
])
|
||||
def test_01_17_TE(self, env: Env, httpd, te_in, te_out):
|
||||
proto = 'h2'
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo'
|
||||
r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
|
||||
with_headers=True,
|
||||
extra_args=['-H', f'TE: {te_in}'])
|
||||
r.check_response(200)
|
||||
if te_out is not None:
|
||||
assert r.responses[0]['header']['request-te'] == te_out, f'{r.responses[0]}'
|
||||
else:
|
||||
assert 'request-te' not in r.responses[0]['header'], f'{r.responses[0]}'
|
||||
|
|
|
|||
|
|
@ -254,6 +254,10 @@ static int curltest_echo_handler(request_rec *r)
|
|||
ct = apr_table_get(r->headers_in, "content-type");
|
||||
ap_set_content_type(r, ct ? ct : "application/octet-stream");
|
||||
|
||||
if(apr_table_get(r->headers_in, "TE"))
|
||||
apr_table_setn(r->headers_out, "Request-TE",
|
||||
apr_table_get(r->headers_in, "TE"));
|
||||
|
||||
bb = apr_brigade_create(r->pool, c->bucket_alloc);
|
||||
/* copy any request body into the response */
|
||||
rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue