MCPcopy Create free account
hub / github.com/apache/trafficserver / send_expect_request

Function send_expect_request

tests/gold_tests/post/expect_client.py:57–77  ·  view source on GitHub ↗

Send an Expect: 100-Continue request. :param sock: The socket to send the request on. :param server_hostname: The hostname of the server to connect to.

(sock: socket.socket, server_hostname: str)

Source from the content-addressed store, hash-verified

55
56
57def send_expect_request(sock: socket.socket, server_hostname: str) -> None:
58 """Send an Expect: 100-Continue request.
59
60 :param sock: The socket to send the request on.
61 :param server_hostname: The hostname of the server to connect to.
62 """
63 # Send the POST request.
64 host_header: bytes = f'Host: {server_hostname}\r\n'.encode()
65 request: bytes = (
66 b"GET /api/1 HTTP/1.1\r\n" + host_header + b"Connection: keep-alive\r\n"
67 b"Content-Length: 3\r\n"
68 b"uuid: expect\r\n"
69 b"Expect: 100-Continue\r\n"
70 b"\r\n")
71 sock.sendall(request)
72 print('Sent Expect: 100-Continue request:')
73 print(request.decode())
74 drain_response(sock)
75 print('Got 100-Continue response.')
76 sock.sendall(b'rst')
77 print('Sent "rst" body.')
78
79
80def drain_response(sock: socket.socket) -> None:

Callers 1

mainFunction · 0.85

Calls 3

drain_responseFunction · 0.70
encodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected