MCPcopy Create free account
hub / github.com/apache/httpd / to_network

Method to_network

test/pyhttpd/ws_util.py:60–78  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

58 return len(self.data) if self.data else 0
59
60 def to_network(self) -> bytes:
61 nd = bytearray()
62 h1 = self.opcode
63 if self.fin:
64 h1 |= 0x80
65 nd.extend(struct.pack("!B", h1))
66 mask_bit = 0x80 if self.mask is not None else 0x0
67 h2 = self.data_len
68 if h2 > 65535:
69 nd.extend(struct.pack("!BQ", 127|mask_bit, h2))
70 elif h2 > 126:
71 nd.extend(struct.pack("!BH", 126|mask_bit, h2))
72 else:
73 nd.extend(struct.pack("!B", h2|mask_bit))
74 if self.mask is not None:
75 nd.extend(self.mask)
76 if self.data is not None:
77 nd.extend(self.data)
78 return nd
79
80 @classmethod
81 def client_ping(cls, data: bytes, mask: bytes = None) -> 'WsFrame':

Callers 3

ws_runFunction · 0.80
do_sendMethod · 0.80

Calls

no outgoing calls

Tested by 3

ws_runFunction · 0.64
do_sendMethod · 0.64