assume keep-alive for HTTP/2

This commit is contained in:
Maximilian Hils 2020-11-24 14:48:22 +01:00
parent 9c3596219d
commit 6d8a315c5d
2 changed files with 5 additions and 1 deletions

View File

@ -167,7 +167,10 @@ def connection_close(http_version, headers):
elif "keep-alive" in tokens: elif "keep-alive" in tokens:
return False return False
return http_version != "HTTP/1.1" and http_version != b"HTTP/1.1" return http_version not in (
"HTTP/1.1", b"HTTP/1.1",
"HTTP/2.0", b"HTTP/2.0",
)
def expected_http_body_size( def expected_http_body_size(

View File

@ -146,6 +146,7 @@ def test_connection_close():
headers = Headers() headers = Headers()
assert connection_close(b"HTTP/1.0", headers) assert connection_close(b"HTTP/1.0", headers)
assert not connection_close(b"HTTP/1.1", headers) assert not connection_close(b"HTTP/1.1", headers)
assert not connection_close(b"HTTP/2.0", headers)
headers["connection"] = "keep-alive" headers["connection"] = "keep-alive"
assert not connection_close(b"HTTP/1.1", headers) assert not connection_close(b"HTTP/1.1", headers)