Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/fragments/server_upgrade_fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ def receive_initial_request(connection):
data += connection.recv(8192)

match = re.search(b'Upgrade: h2c\r\n', data)
if match is not None:
if match is None:
raise RuntimeError("HTTP/2 upgrade not requested!")

# We need to look for the HTTP2-Settings header field. Again, in production
# code you shouldn't use regular expressions for this, but it's good enough
# for the example.
match = re.search(b'HTTP2-Settings: (\\S+)\r\n', data)
if match is not None:
if match is None:
raise RuntimeError("HTTP2-Settings header field not present!")

return match.group(1)
Expand Down