This commit is contained in:
GitHub Merge Button 2011-09-10 13:13:27 -07:00
commit 16a4383167
1 changed files with 4 additions and 4 deletions

View File

@ -26,8 +26,8 @@ if sys.hexversion > 0x3000000:
from io import StringIO
from http.server import SimpleHTTPRequestHandler
from urllib.parse import urlsplit
b2s = lambda buf: buf.decode('latin_1')
s2b = lambda s: s.encode('latin_1')
b2s = lambda buf: buf.decode('latin_1') if isinstance(buf, bytes) else buf
s2b = lambda s: s.encode('latin_1') if isinstance(s, str) else s
else:
# python 2.X
from cStringIO import StringIO
@ -312,7 +312,7 @@ Sec-WebSocket-Accept: %s\r
offset=full_len - (f['length'] % 4),
count=(f['length'] % 4))
c = numpy.bitwise_xor(data, mask).tostring()
f['payload'] = b + c
f['payload'] = s2b(b) + s2b(c)
else:
print("Unmasked frame: %s" % repr(buf))
f['payload'] = buf[(f['hlen'] + has_mask * 4):full_len]
@ -635,7 +635,7 @@ Sec-WebSocket-Accept: %s\r
# Generate the hash value for the accept header
accept = b64encode(sha1(s2b(key + self.GUID)).digest())
response = self.server_handshake_hybi % accept
response = self.server_handshake_hybi % b2s(accept)
if self.base64:
response += "Sec-WebSocket-Protocol: base64\r\n"
else: