()
| 372 | } |
| 373 | |
| 374 | pub fn pick_free_port() -> u16 { |
| 375 | let listener = match TcpListener::bind("127.0.0.1:0") { |
| 376 | Ok(listener) => listener, |
| 377 | Err(err) => panic!("failed to bind free local port: {err}"), |
| 378 | }; |
| 379 | match listener.local_addr() { |
| 380 | Ok(addr) => addr.port(), |
| 381 | Err(err) => panic!("failed to read bound local address: {err}"), |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | pub fn http_agent() -> ureq::Agent { |
| 386 | http_agent_with_timeout(Duration::from_secs(4)) |
no outgoing calls