Wait for the headers to be complete. :param sock: The socket to read from. :returns: The bytes read off the socket.
(sock: socket.socket)
| 21 | |
| 22 | |
| 23 | def wait_for_headers_complete(sock: socket.socket) -> bytes: |
| 24 | """Wait for the headers to be complete. |
| 25 | |
| 26 | :param sock: The socket to read from. |
| 27 | :returns: The bytes read off the socket. |
| 28 | """ |
| 29 | headers = b"" |
| 30 | while True: |
| 31 | data = sock.recv(1024) |
| 32 | if not data: |
| 33 | print("Socket closed.") |
| 34 | break |
| 35 | print(f'Received:\n{data}') |
| 36 | headers += data |
| 37 | if b"\r\n\r\n" in headers: |
| 38 | break |
| 39 | return headers |
| 40 | |
| 41 | |
| 42 | def determine_outstanding_bytes_to_read(read_bytes: bytes) -> int: |
no test coverage detected