MCPcopy Index your code
hub / github.com/php/frankenphp / initServer

Function initServer

caddy/caddy_test.go:28–43  ·  view source on GitHub ↗

initServer initializes a Caddy test server and waits for it to be ready. After InitServer, it polls the server to handle a race condition on macOS where SO_REUSEPORT can briefly route connections to the old listener being shut down, resulting in "connection reset by peer".

(t *testing.T, tester *caddytest.Tester, config string, format string)

Source from the content-addressed store, hash-verified

26// SO_REUSEPORT can briefly route connections to the old listener being shut down,
27// resulting in "connection reset by peer".
28func initServer(t *testing.T, tester *caddytest.Tester, config string, format string) {
29 t.Helper()
30 tester.InitServer(config, format)
31
32 client := &http.Client{Timeout: 1 * time.Second}
33 require.Eventually(t, func() bool {
34 resp, err := client.Get("http://localhost:" + testPort)
35 if err != nil {
36 return false
37 }
38
39 require.NoError(t, resp.Body.Close())
40
41 return true
42 }, 5*time.Second, 100*time.Millisecond, "server failed to become ready")
43}
44
45var testPort = "9080"
46

Callers 15

TestPHPFunction · 0.85
TestLargeRequestFunction · 0.85
TestWorkerFunction · 0.85
TestNamedModuleWorkersFunction · 0.85
TestEnvFunction · 0.85
TestJsonEnvFunction · 0.85
TestPHPServerDirectiveFunction · 0.85
TestPHPServerGlobalsFunction · 0.85

Calls 2

GetMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected