Skip to content

Commit

Permalink
Report about supported versions in websocket negotiation
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jan 5, 2015
1 parent 7025238 commit f96ad8f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def start(self, request):
if err.code == 405:
raise HTTPMethodNotAllowed(request.method, ['GET'])
elif err.code == 400:
raise HTTPBadRequest(text=err.message)
raise HTTPBadRequest(text=err.message, headers=err.headers)
else: # pragma: no cover
raise HTTPInternalServerError() from err

Expand Down
3 changes: 2 additions & 1 deletion aiohttp/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def do_handshake(method, headers, transport, protocols=()):
version = headers.get('SEC-WEBSOCKET-VERSION')
if version not in ('13', '8', '7'):
raise errors.HttpBadRequest(
message='Unsupported version: {}'.format(version))
message='Unsupported version: {}'.format(version),
headers=(('Sec-WebSocket-Version', '13', '8', '7'),))

# check client handshake for validity
key = headers.get('SEC-WEBSOCKET-KEY')
Expand Down

0 comments on commit f96ad8f

Please sign in to comment.