(addr: SocketAddr, request: String)
| 1003 | } |
| 1004 | |
| 1005 | async fn send_plain_http(addr: SocketAddr, request: String) -> String { |
| 1006 | let connect_addr: SocketAddr = format!("127.0.0.1:{}", addr.port()) |
| 1007 | .parse() |
| 1008 | .expect("failed to build loopback connect addr"); |
| 1009 | let mut stream = TcpStream::connect(connect_addr) |
| 1010 | .await |
| 1011 | .expect("failed to connect to test listener"); |
| 1012 | stream |
| 1013 | .write_all(request.as_bytes()) |
| 1014 | .await |
| 1015 | .expect("failed to write request"); |
| 1016 | |
| 1017 | let mut response = Vec::new(); |
| 1018 | let read_result = |
| 1019 | tokio::time::timeout(Duration::from_secs(2), stream.read_to_end(&mut response)) |
| 1020 | .await |
| 1021 | .expect("timed out reading response"); |
| 1022 | if let Err(err) = read_result |
| 1023 | && err.kind() != ErrorKind::ConnectionReset |
| 1024 | { |
| 1025 | panic!("failed to read response: {err}"); |
| 1026 | } |
| 1027 | String::from_utf8_lossy(&response).into_owned() |
| 1028 | } |
| 1029 | |
| 1030 | fn service_request(addr: SocketAddr, extra_headers: &[(&str, &str)]) -> String { |
| 1031 | let mut request = format!( |
no test coverage detected