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

Function send_response

tests/gold_tests/slow_post/quick_server.py:61–74  ·  view source on GitHub ↗

Send an HTTP response. :param sock: The socket to write to. :param abort_early: If True, abort the response before sending the body.

(sock: socket.socket, abort_early: bool)

Source from the content-addressed store, hash-verified

59
60
61def send_response(sock: socket.socket, abort_early: bool) -> None:
62 """Send an HTTP response.
63
64 :param sock: The socket to write to.
65 :param abort_early: If True, abort the response before sending the body.
66 """
67 if abort_early:
68 response = "HTTP/1."
69 else:
70 response = ("HTTP/1.1 200 OK\r\n"
71 "Content-Length: 0\r\n"
72 "\r\n")
73 print(f'Sending:\n{response}')
74 sock.sendall(response.encode("utf-8"))
75
76
77def main() -> int:

Callers 1

mainFunction · 0.85

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected