()
| 2 | |
| 3 | #[wstd::main] |
| 4 | async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 5 | // Set first byte timeout to 1/2 second. |
| 6 | let mut client = Client::new(); |
| 7 | client.set_first_byte_timeout(std::time::Duration::from_millis(500)); |
| 8 | // This get request will connect to the server, which will then wait 1 second before |
| 9 | // returning a response. |
| 10 | let request = Request::get("https://postman-echo.com/delay/1").body(Body::empty())?; |
| 11 | let result = client.send(request).await; |
| 12 | |
| 13 | assert!(result.is_err(), "response should be an error"); |
| 14 | let error = result.unwrap_err(); |
| 15 | assert!( |
| 16 | matches!( |
| 17 | error.downcast_ref::<ErrorCode>(), |
| 18 | Some(ErrorCode::ConnectionReadTimeout) |
| 19 | ), |
| 20 | "expected ConnectionReadTimeout error, got: {error:?>}" |
| 21 | ); |
| 22 | |
| 23 | Ok(()) |
| 24 | } |
nothing calls this directly
no test coverage detected