-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Getallheaders fpm 5.6 #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2e3bb0d
Update NEWS after rebase.
LawnGnome 1ed0df4
NEWS
remicollet 8c5a3e6
update NEWS
smalyshev 52af4cf
fix NEWS order
smalyshev 8bddb49
getallheaders for php-fpm #62596
krakjoe 7eb3704
Fixes the trailing header and refactors add_request_headers()
ralt 4f76531
Adds getallheaders() test to fpm
ralt 2e0db17
s
ralt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--TEST-- | ||
FPM: Test getallheaders() function | ||
--SKIPIF-- | ||
<?php include "skipif.inc"; ?> | ||
--FILE-- | ||
<?php | ||
|
||
include "include.inc"; | ||
|
||
$logfile = __DIR__.'/php-fpm.log.tmp'; | ||
$srcfile = __DIR__.'/php-fpm.tmp.php'; | ||
$port = 9000+PHP_INT_SIZE; | ||
|
||
$cfg = <<<EOT | ||
[global] | ||
error_log = $logfile | ||
[unconfined] | ||
listen = 127.0.0.1:$port | ||
pm = dynamic | ||
pm.max_children = 5 | ||
pm.start_servers = 1 | ||
pm.min_spare_servers = 1 | ||
pm.max_spare_servers = 3 | ||
EOT; | ||
|
||
$code = <<<EOT | ||
<?php | ||
echo "Test Start\n"; | ||
var_dump(getallheaders()); | ||
echo "Test End\n"; | ||
EOT; | ||
file_put_contents($srcfile, $code); | ||
|
||
$fpm = run_fpm($cfg, $tail); | ||
if (is_resource($fpm)) { | ||
fpm_display_log($tail, 2); | ||
try { | ||
$headers = [ | ||
'HTTP_X_FOO' => 'BAR', | ||
'HTTP_CONTENT_TYPE' => 'text/html; charset=UTF-8', | ||
]; | ||
$req = run_request('127.0.0.1', $port, $srcfile, ''); | ||
echo strstr($req, "Test Start"); | ||
echo "Request ok\n"; | ||
} catch (Exception $e) { | ||
echo "Request error\n"; | ||
} | ||
proc_terminate($fpm); | ||
echo stream_get_contents($tail); | ||
fclose($tail); | ||
proc_close($fpm); | ||
} | ||
|
||
?> | ||
Done | ||
--EXPECTF-- | ||
[%s] NOTICE: fpm is running, pid %d | ||
[%s] NOTICE: ready to handle connections | ||
Test Start | ||
array(1) { | ||
["X-Foo"]=> | ||
string(4) "Bar" | ||
} | ||
Test End | ||
|
||
Request ok | ||
[%s] NOTICE: Terminating ... | ||
[%s] NOTICE: exiting, bye-bye! | ||
Done | ||
--CLEAN-- | ||
<?php | ||
$logfile = __DIR__.'/php-fpm.log.tmp'; | ||
$srcfile = __DIR__.'/php-fpm.log.tmp'; | ||
@unlink($logfile); | ||
@unlink($srcfile); | ||
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to actually preserve the header case? This naïve algorithm won't work properly for certain headers, and would break poorly-written code that relies on header case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't checked for FPM, but doing a "strace" on a FastCGI-only process shows that the headers are transmitted in upper case, no matter what they looked like in the original request. I guess FPM will receive the same data when using mod_fastcgi on Apache.
Might be different with other implementations, like mod_proxy_fcgi (or other web server), but an existing case sensitive code would already not work is most cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's unfortunate :/
OK then. Could this code be shared with the other places in PHP that use the same algorithm? CGI and FastCGI already have way too much copy-pasting.