-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add headers handler in CLI SAPI #16145
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
Open
joanhey
wants to merge
8
commits into
php:master
Choose a base branch
from
joanhey:cli-header-handler
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c699b08
CLI use default header handler
joanhey f84bcda
Add cli headers tests
joanhey 4da1c3d
Remove INI in sent test
joanhey 1accb94
FIx session test name
joanhey 748ae87
Change head.phpt
joanhey f7a6eee
Fix head.phpt
joanhey 1a81372
Fix to not break with other PHP versions
joanhey 7815596
Small change to rerun CI
joanhey 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--TEST-- | ||
CLI header(), header_remove() and headers_list() | ||
--SKIPIF-- | ||
<?php include "skipif.inc" ?> | ||
--INI-- | ||
expose_php=On | ||
--FILE-- | ||
<?php | ||
header("A: first"); | ||
header("A: second", TRUE); | ||
$headers1 = headers_list(); | ||
header("A: third", FALSE); | ||
$headers2 = headers_list(); | ||
header_remove("A"); | ||
$headers3 = headers_list(); | ||
print_r($headers1); | ||
print_r($headers2); | ||
print_r($headers3); | ||
?> | ||
--EXPECTF-- | ||
Array | ||
( | ||
[0] => X-Powered-By: %s | ||
[1] => A: second | ||
) | ||
Array | ||
( | ||
[0] => X-Powered-By: %s | ||
[1] => A: second | ||
[2] => A: third | ||
) | ||
Array | ||
( | ||
[0] => X-Powered-By: %s | ||
) |
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,24 @@ | ||
--TEST-- | ||
CLI session create header | ||
--SKIPIF-- | ||
<?php include "skipif.inc"; ?> | ||
--INI-- | ||
expose_php=On | ||
--FILE-- | ||
<?php | ||
session_name("foo"); | ||
session_id('bar'); | ||
session_start(); | ||
|
||
$headers = headers_list(); | ||
print_r($headers); | ||
?> | ||
--EXPECTF-- | ||
Array | ||
( | ||
[0] => X-Powered-By: %s | ||
[1] => Set-Cookie: foo=bar; path=/ | ||
[2] => Expires: %s | ||
[3] => Cache-Control: no-store, no-cache, must-revalidate | ||
[4] => Pragma: no-cache | ||
) |
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,22 @@ | ||
--TEST-- | ||
CLI setcookie() create header | ||
--SKIPIF-- | ||
<?php include "skipif.inc"; ?> | ||
--INI-- | ||
expose_php=On | ||
--FILE-- | ||
<?php | ||
setcookie('hi', time()+3600); | ||
|
||
setcookie('hi'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please duplicate the test with setrawcookie function |
||
|
||
$headers = headers_list(); | ||
print_r($headers); | ||
?> | ||
--EXPECTF-- | ||
Array | ||
( | ||
[0] => X-Powered-By: %s | ||
[1] => Set-Cookie: hi=%s | ||
[2] => Set-Cookie: hi=deleted;%s | ||
) |
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,35 @@ | ||
--TEST-- | ||
CLI headers_sent() | ||
--SKIPIF-- | ||
<?php include "skipif.inc" ?> | ||
--FILE-- | ||
<?php | ||
$sent1 = headers_sent(); | ||
|
||
fwrite(STDOUT, "Hi !!"); | ||
$sent2 = headers_sent(); | ||
|
||
ob_start(); | ||
echo "Bye !!\n"; | ||
$sent3 = headers_sent(); | ||
|
||
$out = ob_get_clean(); | ||
$sent4 = headers_sent(); | ||
|
||
echo $out; | ||
|
||
var_dump( | ||
$sent1, | ||
$sent2, | ||
$sent3, | ||
$sent4, | ||
headers_sent() | ||
); | ||
?> | ||
--EXPECT-- | ||
Hi !!Bye !! | ||
bool(false) | ||
bool(false) | ||
bool(false) | ||
bool(false) | ||
bool(true) |
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.
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 would leave the
X-Powered-By
header test separately and remove it by default in the others.