Here are the examples of the python api aiohttp._ws_impl.PACK_LEN3 taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
Example 1
Project: aiohttp Source File: test_websocket_parser.py
def build_frame(message, opcode, use_mask=False, noheader=False):
"""Send a frame over the websocket with message as its payload."""
msg_length = len(message)
if use_mask: # pragma: no cover
mask_bit = 0x80
else:
mask_bit = 0
if msg_length < 126:
header = PACK_LEN1(
0x80 | opcode, msg_length | mask_bit)
elif msg_length < (1 << 16): # pragma: no cover
header = PACK_LEN2(
0x80 | opcode, 126 | mask_bit, msg_length)
else:
header = PACK_LEN3(
0x80 | opcode, 127 | mask_bit, msg_length)
if use_mask: # pragma: no cover
mask = random.randrange(0, 0xffffffff)
mask = mask.to_bytes(4, 'big')
message = _websocket_mask(mask, bytearray(message))
if noheader:
return message
else:
return header + mask + message
else:
if noheader:
return message
else:
return header + message