MCPcopy Create free account
hub / github.com/python-websockets/websockets / build_request

Function build_request

src/websockets/legacy/handshake.py:16–34  ·  view source on GitHub ↗

Build a handshake request to send to the server. Update request headers passed in argument. Args: headers: Handshake request headers. Returns: ``key`` that must be passed to :func:`check_response`.

(headers: Headers)

Source from the content-addressed store, hash-verified

14
15
16def build_request(headers: Headers) -> str:
17 """
18 Build a handshake request to send to the server.
19
20 Update request headers passed in argument.
21
22 Args:
23 headers: Handshake request headers.
24
25 Returns:
26 ``key`` that must be passed to :func:`check_response`.
27
28 """
29 key = generate_key()
30 headers["Upgrade"] = "websocket"
31 headers["Connection"] = "Upgrade"
32 headers["Sec-WebSocket-Key"] = key
33 headers["Sec-WebSocket-Version"] = "13"
34 return key
35
36
37def check_request(headers: Headers) -> str:

Callers 4

handshakeMethod · 0.85
test_round_tripMethod · 0.85

Calls 1

generate_keyFunction · 0.85

Tested by 3

test_round_tripMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…