mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
@@ -608,7 +608,7 @@ func TestAllDefinedServerVars(t *testing.T) {
|
||||
"Content-Type: application/x-www-form-urlencoded",
|
||||
"Content-Length: 14", // maliciously set to 14
|
||||
"Special-Chars: <%00>",
|
||||
"Host: Malicous Host",
|
||||
"Host: Malicious Host",
|
||||
"X-Empty-Header:",
|
||||
},
|
||||
bytes.NewBufferString("foo=bar"),
|
||||
|
||||
@@ -19,7 +19,7 @@ FROM dunglas/frankenphp
|
||||
# Production:
|
||||
RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
|
||||
|
||||
# Or developement:
|
||||
# Or development:
|
||||
RUN cp $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini
|
||||
```
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ Refer to "[Building Custom Docker Image](docker.md)" for more details and option
|
||||
and to learn how to customize the configuration, install PHP extensions and Caddy modules.
|
||||
|
||||
If your project uses Composer,
|
||||
be sure to include it in the Docker image and to install your depedencies.
|
||||
be sure to include it in the Docker image and to install your dependencies.
|
||||
|
||||
Then, add a `compose.yaml` file:
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ PHP_FUNCTION(frankenphp_handle_request) {
|
||||
}
|
||||
|
||||
/*
|
||||
* If an exception occured, print the message to the client before closing the
|
||||
* If an exception occurred, print the message to the client before closing the
|
||||
* connection
|
||||
*/
|
||||
if (EG(exception)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// In all tests, headers added to requests are copied on the heap using strings.Clone.
|
||||
// This was originally a workaround for https://github.com/golang/go/issues/65286#issuecomment-1920087884 (fixed in Go 1.22),
|
||||
// but this allows to catch panics occuring in real life but not when the string is in the internal binary memory.
|
||||
// but this allows to catch panics occurring in real life but not when the string is in the internal binary memory.
|
||||
|
||||
package frankenphp_test
|
||||
|
||||
@@ -41,7 +41,7 @@ type testOptions struct {
|
||||
watch []string
|
||||
nbWorkers int
|
||||
env map[string]string
|
||||
nbParrallelRequests int
|
||||
nbParallelRequests int
|
||||
realServer bool
|
||||
logger *zap.Logger
|
||||
initOpts []frankenphp.Option
|
||||
@@ -51,8 +51,8 @@ func runTest(t *testing.T, test func(func(http.ResponseWriter, *http.Request), *
|
||||
if opts == nil {
|
||||
opts = &testOptions{}
|
||||
}
|
||||
if opts.nbParrallelRequests == 0 {
|
||||
opts.nbParrallelRequests = 100
|
||||
if opts.nbParallelRequests == 0 {
|
||||
opts.nbParallelRequests = 100
|
||||
}
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
@@ -87,8 +87,8 @@ func runTest(t *testing.T, test func(func(http.ResponseWriter, *http.Request), *
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(opts.nbParrallelRequests)
|
||||
for i := 0; i < opts.nbParrallelRequests; i++ {
|
||||
wg.Add(opts.nbParallelRequests)
|
||||
for i := 0; i < opts.nbParallelRequests; i++ {
|
||||
go func(i int) {
|
||||
test(handler, ts, i)
|
||||
wg.Done()
|
||||
@@ -850,7 +850,7 @@ func BenchmarkServerSuperGlobal(b *testing.B) {
|
||||
cwd, _ := os.Getwd()
|
||||
testDataDir := cwd + "/testdata/"
|
||||
|
||||
// Mimicks headers of a request sent by Firefox to GitHub
|
||||
// Mimics headers of a request sent by Firefox to GitHub
|
||||
headers := http.Header{}
|
||||
headers.Add(strings.Clone("Accept"), strings.Clone("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"))
|
||||
headers.Add(strings.Clone("Accept-Encoding"), strings.Clone("gzip, deflate, br"))
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestWorkersShouldReloadOnMatchingPattern(t *testing.T) {
|
||||
runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {
|
||||
requestBodyHasReset := pollForWorkerReset(t, handler, maxTimesToPollForChanges)
|
||||
assert.True(t, requestBodyHasReset)
|
||||
}, &testOptions{nbParrallelRequests: 1, nbWorkers: 1, workerScript: "worker-with-watcher.php", watch: watch})
|
||||
}, &testOptions{nbParallelRequests: 1, nbWorkers: 1, workerScript: "worker-with-watcher.php", watch: watch})
|
||||
}
|
||||
|
||||
func TestWorkersShouldNotReloadOnExcludingPattern(t *testing.T) {
|
||||
@@ -38,7 +38,7 @@ func TestWorkersShouldNotReloadOnExcludingPattern(t *testing.T) {
|
||||
runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {
|
||||
requestBodyHasReset := pollForWorkerReset(t, handler, minTimesToPollForChanges)
|
||||
assert.False(t, requestBodyHasReset)
|
||||
}, &testOptions{nbParrallelRequests: 1, nbWorkers: 1, workerScript: "worker-with-watcher.php", watch: watch})
|
||||
}, &testOptions{nbParallelRequests: 1, nbWorkers: 1, workerScript: "worker-with-watcher.php", watch: watch})
|
||||
}
|
||||
|
||||
func fetchBody(method string, url string, handler func(http.ResponseWriter, *http.Request)) string {
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestWorker(t *testing.T) {
|
||||
body2, _ := io.ReadAll(resp2.Body)
|
||||
|
||||
assert.Contains(t, string(body2), fmt.Sprintf("Requests handled: %d", i*2+1))
|
||||
}, &testOptions{workerScript: "worker.php", nbWorkers: 1, nbParrallelRequests: 1})
|
||||
}, &testOptions{workerScript: "worker.php", nbWorkers: 1, nbParallelRequests: 1})
|
||||
}
|
||||
|
||||
func TestWorkerDie(t *testing.T) {
|
||||
@@ -51,7 +51,7 @@ func TestWorkerDie(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", "http://example.com/die.php", nil)
|
||||
w := httptest.NewRecorder()
|
||||
handler(w, req)
|
||||
}, &testOptions{workerScript: "die.php", nbWorkers: 1, nbParrallelRequests: 10})
|
||||
}, &testOptions{workerScript: "die.php", nbWorkers: 1, nbParallelRequests: 10})
|
||||
}
|
||||
|
||||
func TestNonWorkerModeAlwaysWorks(t *testing.T) {
|
||||
@@ -90,7 +90,7 @@ func TestWorkerEnv(t *testing.T) {
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
|
||||
assert.Equal(t, fmt.Sprintf("bar%d", i), string(body))
|
||||
}, &testOptions{workerScript: "worker-env.php", nbWorkers: 1, env: map[string]string{"FOO": "bar"}, nbParrallelRequests: 10})
|
||||
}, &testOptions{workerScript: "worker-env.php", nbWorkers: 1, env: map[string]string{"FOO": "bar"}, nbParallelRequests: 10})
|
||||
}
|
||||
|
||||
func TestWorkerGetOpt(t *testing.T) {
|
||||
@@ -150,5 +150,5 @@ func TestWorkerHasOSEnvironmentVariableInSERVER(t *testing.T) {
|
||||
|
||||
assert.Contains(t, string(body), "CUSTOM_OS_ENV_VARIABLE")
|
||||
assert.Contains(t, string(body), "custom_env_variable_value")
|
||||
}, &testOptions{workerScript: "worker.php", nbWorkers: 1, nbParrallelRequests: 1})
|
||||
}, &testOptions{workerScript: "worker.php", nbWorkers: 1, nbParallelRequests: 1})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user