diff options
| author | Mark <56205165+gamblor21@users.noreply.github.com> | 2021-03-15 20:00:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-15 20:00:13 -0500 |
| commit | e326d7ca800ce7101ddce001320c5349ee5ddeb6 (patch) | |
| tree | 000a06790af7a8d27e9ba9fc27e10015815e1509 /tests/extmod/websocket_basic.py | |
| parent | 307d2a99febbf6cdff824131dddc2ef938f5ea13 (diff) | |
| parent | f7a988b9b307141611b07f6dc9da5b26e982c154 (diff) | |
Merge branch 'main' into rp_dp_parallel
Diffstat (limited to 'tests/extmod/websocket_basic.py')
| -rw-r--r-- | tests/extmod/websocket_basic.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/extmod/websocket_basic.py b/tests/extmod/websocket_basic.py index 9a80503a0..8c5cf5825 100644 --- a/tests/extmod/websocket_basic.py +++ b/tests/extmod/websocket_basic.py @@ -11,6 +11,7 @@ def ws_read(msg, sz): ws = websocket.websocket(uio.BytesIO(msg)) return ws.read(sz) + # do a websocket write and then return the raw data from the stream def ws_write(msg, sz): s = uio.BytesIO() @@ -19,31 +20,32 @@ def ws_write(msg, sz): s.seek(0) return s.read(sz) + # basic frame print(ws_read(b"\x81\x04ping", 4)) -print(ws_read(b"\x80\x04ping", 4)) # FRAME_CONT +print(ws_read(b"\x80\x04ping", 4)) # FRAME_CONT print(ws_write(b"pong", 6)) # split frames are not supported # print(ws_read(b"\x01\x04ping", 4)) # extended payloads -print(ws_read(b'\x81~\x00\x80' + b'ping' * 32, 128)) +print(ws_read(b"\x81~\x00\x80" + b"ping" * 32, 128)) print(ws_write(b"pong" * 32, 132)) # mask (returned data will be 'mask' ^ 'mask') print(ws_read(b"\x81\x84maskmask", 4)) # close control frame -s = uio.BytesIO(b'\x88\x00') # FRAME_CLOSE +s = uio.BytesIO(b"\x88\x00") # FRAME_CLOSE ws = websocket.websocket(s) print(ws.read(1)) s.seek(2) print(s.read(4)) # misc control frames -print(ws_read(b"\x89\x00\x81\x04ping", 4)) # FRAME_PING -print(ws_read(b"\x8a\x00\x81\x04pong", 4)) # FRAME_PONG +print(ws_read(b"\x89\x00\x81\x04ping", 4)) # FRAME_PING +print(ws_read(b"\x8a\x00\x81\x04pong", 4)) # FRAME_PONG # close method ws = websocket.websocket(uio.BytesIO()) @@ -51,8 +53,8 @@ ws.close() # ioctl ws = websocket.websocket(uio.BytesIO()) -print(ws.ioctl(8)) # GET_DATA_OPTS -print(ws.ioctl(9, 2)) # SET_DATA_OPTS +print(ws.ioctl(8)) # GET_DATA_OPTS +print(ws.ioctl(9, 2)) # SET_DATA_OPTS print(ws.ioctl(9)) try: ws.ioctl(-1) |
