diff --git a/aiohttp/http_parser.py b/aiohttp/http_parser.py index d31a62042e7..49058456934 100644 --- a/aiohttp/http_parser.py +++ b/aiohttp/http_parser.py @@ -327,6 +327,12 @@ def parse_headers(self, lines): elif v == 'upgrade': upgrade = True + # restrict connection upgrade to supported protocols + upgrade_to = headers.get(hdrs.UPGRADE) + if upgrade_to: + v = conn.lower() + upgrade = upgrade and v in {'websocket'} + # encoding enc = headers.get(hdrs.CONTENT_ENCODING) if enc: