def test_http_unsupported_method(tcp_client): tcp_client.sendall("PUT\r\n\r\n".encode()) assert tcp_client.recv(1024) == b''
def test_http_get_incomplete_request_path(tcp_client): tcp_client.sendall("GET /asdf\r\n\r\n".encode()) assert tcp_client.recv(1024) == b''
def test_http_incomplete_request(tcp_client): tcp_client.sendall("G\r\n\r\n".encode()) assert tcp_client.recv(1024) == b''
def test_http_get_illegal_path_404(tcp_client): tcp_client.sendall( "GET /../.. HTTP/1.1\r\nHost: localhost\r\n\r\n".encode()) assert tcp_client.recv(1024).decode().startswith("HTTP/1.1 403")
def test_echo(tcp_client): data = " Hello how are you?\n" tcp_client.sendall(data.encode()) assert tcp_client.recv(1024).decode() == data
def test_multi_echo(tcp_client): for i in range(1000): data = " Hello how are you?\n" tcp_client.sendall(data.encode()) assert tcp_client.recv(1024).decode() == data