Skip to content

Commit

Permalink
fix bug when sec-websocket-protocol and sec-websocket-extensions appe…
Browse files Browse the repository at this point in the history
…ar in header
  • Loading branch information
Seraphli committed Aug 30, 2017
1 parent cdf50bd commit 4cbdcd6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ws4py/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ def process_handshake_header(self, headers):
raise HandshakeError("Invalid challenge response: %s" % value)

elif header == b'sec-websocket-protocol':
protocols = ','.join(value)
protocols.append(value.decode('utf-8'))

elif header == b'sec-websocket-extensions':
extensions = ','.join(value)
extensions.append(value.decode('utf-8'))

return protocols, extensions

Expand Down

2 comments on commit 4cbdcd6

@medington
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this change does address the simple failure case of one protocol, it still does not properly handle the case where the client is created with an array of protocol values (same for extensions).

A more correct change is:

protocols.extend([x.strip() for x in value.split(b',')])

This fix is is included in Pull Request #219.

@Lawouach
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. When Iooked at it yesterday, I sort of recalled this could be a case but not quite sure. I do not use this project myself and I must admit I didn't clearly remember the details. I probably should have been more careful.

Please sign in to comment.