File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,21 +36,20 @@ def server_handshake(sock):
3636 if DEBUG :
3737 print ("Sec-WebSocket-Key:" , webkey , len (webkey ))
3838
39- respkey = webkey + b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
40- respkey = hashlib .sha1 (respkey ).digest ()
39+ d = hashlib .sha1 (webkey )
40+ d .update (b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" )
41+ respkey = d .digest ()
4142 respkey = binascii .b2a_base64 (respkey )[:- 1 ]
43+ if DEBUG :
44+ print ("respkey:" , resp )
4245
43- resp = b"""\
46+ sock . send ( b"""\
4447 HTTP/1.1 101 Switching Protocols\r
4548Upgrade: websocket\r
4649Connection: Upgrade\r
47- Sec-WebSocket-Accept: %s\r
48- \r
49- """ % respkey
50-
51- if DEBUG :
52- print (resp )
53- sock .send (resp )
50+ Sec-WebSocket-Accept: """ )
51+ sock .send (respkey )
52+ sock .send ("\r \n \r \n " )
5453
5554
5655# Very simplified client handshake, works for MicroPython's
You can’t perform that action at this time.
0 commit comments