Skip to content
Snippets Groups Projects
Commit d422e566 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

esp8266/scripts/websocket_helper: Disable debug output.

parent eb407696
No related branches found
No related tags found
No related merge requests found
......@@ -8,11 +8,12 @@ try:
except:
import hashlib
DEBUG = 0
def server_handshake(sock):
clr = sock.makefile("rwb", 0)
l = clr.readline()
sys.stdout.write(repr(l))
#sys.stdout.write(repr(l))
webkey = None
......@@ -24,6 +25,7 @@ def server_handshake(sock):
break
# sys.stdout.write(l)
h, v = [x.strip() for x in l.split(b":", 1)]
if DEBUG:
print((h, v))
if h == b'Sec-WebSocket-Key':
webkey = v
......@@ -31,13 +33,12 @@ def server_handshake(sock):
if not webkey:
raise OSError("Not a websocket request")
print(webkey, len(webkey))
if DEBUG:
print("Sec-WebSocket-Key:", webkey, len(webkey))
respkey = webkey + b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
respkey = hashlib.sha1(respkey).digest()
print(repr(respkey))
respkey = binascii.b2a_base64(respkey)[:-1]
print(repr(respkey))
resp = b"""\
HTTP/1.1 101 Switching Protocols\r
......@@ -47,6 +48,7 @@ Sec-WebSocket-Accept: %s\r
\r
""" % respkey
if DEBUG:
print(resp)
sock.send(resp)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment