freePort returns a free local TCP port by binding briefly and releasing it.
(t *testing.T)
| 367 | |
| 368 | // freePort returns a free local TCP port by binding briefly and releasing it. |
| 369 | func freePort(t *testing.T) int { |
| 370 | t.Helper() |
| 371 | ln, err := net.Listen("tcp", "127.0.0.1:0") |
| 372 | if err != nil { |
| 373 | t.Fatalf("freePort: %v", err) |
| 374 | } |
| 375 | port := ln.Addr().(*net.TCPAddr).Port |
| 376 | _ = ln.Close() |
| 377 | return port |
| 378 | } |
| 379 | |
| 380 | // TestProxyProtocolV1WithH1 verifies that PROXY protocol v1 headers are sent |
| 381 | // correctly when the transport uses HTTP/1.1 to the upstream. |
no test coverage detected