Skip to content

Commit d422e56

Browse files
committed
esp8266/scripts/websocket_helper: Disable debug output.
1 parent eb40769 commit d422e56

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

esp8266/scripts/websocket_helper.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
except:
99
import hashlib
1010

11+
DEBUG = 0
1112

1213
def server_handshake(sock):
1314
clr = sock.makefile("rwb", 0)
1415
l = clr.readline()
15-
sys.stdout.write(repr(l))
16+
#sys.stdout.write(repr(l))
1617

1718
webkey = None
1819

@@ -24,20 +25,20 @@ def server_handshake(sock):
2425
break
2526
# sys.stdout.write(l)
2627
h, v = [x.strip() for x in l.split(b":", 1)]
27-
print((h, v))
28+
if DEBUG:
29+
print((h, v))
2830
if h == b'Sec-WebSocket-Key':
2931
webkey = v
3032

3133
if not webkey:
3234
raise OSError("Not a websocket request")
3335

34-
print(webkey, len(webkey))
36+
if DEBUG:
37+
print("Sec-WebSocket-Key:", webkey, len(webkey))
3538

3639
respkey = webkey + b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
3740
respkey = hashlib.sha1(respkey).digest()
38-
print(repr(respkey))
3941
respkey = binascii.b2a_base64(respkey)[:-1]
40-
print(repr(respkey))
4142

4243
resp = b"""\
4344
HTTP/1.1 101 Switching Protocols\r
@@ -47,7 +48,8 @@ def server_handshake(sock):
4748
\r
4849
""" % respkey
4950

50-
print(resp)
51+
if DEBUG:
52+
print(resp)
5153
sock.send(resp)
5254

5355

0 commit comments

Comments
 (0)