Skip to content

Commit

Permalink
Fix flake8.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerdonek committed Jul 19, 2017
1 parent 3f8a7c0 commit e83b826
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions websockets/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def handler(self):
# it attemps to log relevant ones and close the connection properly.
try:
try:
response_headers = yield from self.pre_handshake(origins=self.origins)
response_headers = (
yield from self.pre_handshake(origins=self.origins))
if response_headers is None:
# Then the response was already written.
return
Expand Down Expand Up @@ -275,7 +276,8 @@ def pre_handshake(self, origins=None):
yield from self.close_connection(force=True)

@asyncio.coroutine
def handshake(self, response_headers, subprotocols=None, extra_headers=None):
def handshake(self, response_headers, subprotocols=None,
extra_headers=None):
"""
Perform the server side of the opening handshake.
Expand Down Expand Up @@ -304,14 +306,16 @@ def handshake(self, response_headers, subprotocols=None, extra_headers=None):
set_header('Sec-WebSocket-Protocol', self.subprotocol)
if extra_headers is not None:
if callable(extra_headers):
extra_headers = extra_headers(self.path, self.raw_request_headers)
extra_headers = extra_headers(self.path,
self.raw_request_headers)
if isinstance(extra_headers, collections.abc.Mapping):
extra_headers = extra_headers.items()
for name, value in extra_headers:
set_header(name, value)
build_response(set_header, key)

yield from self.write_http_response(SWITCHING_PROTOCOLS, response_headers)
yield from self.write_http_response(SWITCHING_PROTOCOLS,
response_headers)

assert self.state == CONNECTING
self.state = OPEN
Expand Down

0 comments on commit e83b826

Please sign in to comment.