Skip to content

Commit

Permalink
Merge 181f9e8 into f324205
Browse files Browse the repository at this point in the history
  • Loading branch information
smandy committed Jun 16, 2016
2 parents f324205 + 181f9e8 commit 50e5439
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cyclone/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def messageReceived(self, message):
"""Gets called when a message is received from the peer."""
pass

def sendMessage(self, message):
def sendMessage(self, message, isBinary = False):
"""Sends the given message to the client of this Web Socket.
The message may be either a string or a dict (which will be
Expand All @@ -112,7 +112,11 @@ def sendMessage(self, message):
if isinstance(message, unicode):
message = message.encode("utf-8")
assert isinstance(message, str)
self.ws_protocol.sendMessage(message)
if isBinary:
code = 0x82
else:
code = 0x81
self.ws_protocol.sendMessage(message, code = code)

def _rawDataReceived(self, data):
self.ws_protocol.handleRawData(data)
Expand Down Expand Up @@ -192,8 +196,10 @@ def acceptConnection(self):
# simply "Origin".
if 'Origin' in self.request.headers:
origin = self.request.headers['Origin']
else:
elif 'Sec-Websocket-Origin' in self.request.headers:
origin = self.request.headers['Sec-Websocket-Origin']
else:
origin = "UNKNOWN"

key = self.request.headers['Sec-Websocket-Key']
accept = base64.b64encode(hashlib.sha1("%s%s" %
Expand Down

0 comments on commit 50e5439

Please sign in to comment.