Skip to content

Commit

Permalink
Do not swallow Upgrade header #1587
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Kim committed Feb 6, 2017
1 parent 964921d commit d175e4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ CHANGES

- Separate read + connect + request timeouts # 1523

- Do not swallow Upgrade header #1587

- Fix polls demo run application #1487

- Ignore unknown 1XX status codes in client #1353
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def add_header(self, name, value):
elif name == hdrs.UPGRADE:
if 'websocket' in value.lower():
self.websocket = True
self.headers[name] = value
self.headers[name] = value

elif name not in self.HOP_HEADERS:
# ignore hop-by-hop headers
Expand Down
6 changes: 4 additions & 2 deletions tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ def test_add_headers_upgrade(transport):

def test_add_headers_upgrade_websocket(transport):
msg = protocol.Response(transport, 200)

msg.add_headers(('upgrade', 'test'))
assert [] == list(msg.headers)
assert not msg.websocket
assert [('Upgrade', 'test')] == list(msg.headers.items())

msg = protocol.Response(transport, 200)
msg.add_headers(('upgrade', 'websocket'))
assert msg.websocket
assert [('Upgrade', 'websocket')] == list(msg.headers.items())


Expand Down

0 comments on commit d175e4e

Please sign in to comment.