Skip to content

Commit

Permalink
🐛 Fixed protocol violation when the Connection header is sent for HTT…
Browse files Browse the repository at this point in the history
…P/2 and HTTP/3 (#16)

…
  • Loading branch information
Ousret authored Sep 12, 2023
1 parent 97fafa1 commit 4b86435
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog/16.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed protocol violation for HTTP/2 and HTTP/3 where we sent ``Connection: keep-alive`` when it is
forbidden.
7 changes: 7 additions & 0 deletions src/urllib3/backend/hface.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,13 @@ def endheaders(
except ValueError:
pass

# Passing 'Connection' header is actually a protocol violation above h11.
# We assume it is passed as-is (meaning 'keep-alive' lower-cased)
try:
self.__headers.remove((b"connection", b"keep-alive"))
except ValueError:
pass

# some quic/h3 implementation like quic-go skip reading the body
# if this indicator isn't present, equivalent to te: chunked but looking for stream FIN marker.
# officially, it should not be there. kept for compatibility.
Expand Down

0 comments on commit 4b86435

Please sign in to comment.