mirror of
https://github.com/dunglas/frankenphp
synced 2024-11-23 08:39:21 +00:00
fix: reset sapi response code (#964)
Some checks are pending
Lint Code Base / Lint Code Base (push) Waiting to run
Sanitizers / ${{ matrix.sanitizer }} (asan) (push) Waiting to run
Sanitizers / ${{ matrix.sanitizer }} (msan) (push) Waiting to run
Tests / tests (8.2) (push) Waiting to run
Tests / tests (8.3) (push) Waiting to run
Some checks are pending
Lint Code Base / Lint Code Base (push) Waiting to run
Sanitizers / ${{ matrix.sanitizer }} (asan) (push) Waiting to run
Sanitizers / ${{ matrix.sanitizer }} (msan) (push) Waiting to run
Tests / tests (8.2) (push) Waiting to run
Tests / tests (8.3) (push) Waiting to run
* fix: reset sapi response code It turns out that the sapi response code is NOT reset between requests by the zend engine. This resets the code for cgi-based requests. fixes: #960 * update response header test * fix assertion * appears to affect workers too
This commit is contained in:
parent
3ca52f5934
commit
d532772355
@ -455,6 +455,9 @@ int frankenphp_update_server_context(
|
||||
ctx = (frankenphp_server_context *)SG(server_context);
|
||||
}
|
||||
|
||||
// It is not reset by zend engine, set it to 200.
|
||||
SG(sapi_headers).http_response_code = 200;
|
||||
|
||||
ctx->main_request = main_request;
|
||||
ctx->current_request = current_request;
|
||||
|
||||
|
@ -246,6 +246,12 @@ func testResponseHeaders(t *testing.T, opts *testOptions) {
|
||||
resp := w.Result()
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
|
||||
if i%3 != 0 {
|
||||
assert.Equal(t, i+100, resp.StatusCode)
|
||||
} else {
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
}
|
||||
|
||||
assert.Contains(t, string(body), "'X-Powered-By' => 'PH")
|
||||
assert.Contains(t, string(body), "'Foo' => 'bar',")
|
||||
assert.Contains(t, string(body), "'Foo2' => 'bar2',")
|
||||
|
6
testdata/response-headers.php
vendored
6
testdata/response-headers.php
vendored
@ -7,7 +7,9 @@ return function () {
|
||||
header('Foo2: bar2');
|
||||
header('Invalid');
|
||||
header('I: ' . ($_GET['i'] ?? 'i not set'));
|
||||
http_response_code(201);
|
||||
|
||||
if ($_GET['i'] % 3) {
|
||||
http_response_code($_GET['i'] + 100);
|
||||
}
|
||||
|
||||
var_export(apache_response_headers());
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user