-
Notifications
You must be signed in to change notification settings - Fork 7.9k
tests(ext-curl): fix HTTP/2 Server Push tests #10669
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
9 commits
Select commit
Hold shift + click to select a range
668cb44
tests(ext-curl): fix HTTP/2 Server Push tests
dunglas 348f2f3
wip
dunglas 017ed85
better Caddy install and detection
dunglas f2cb98c
try again
dunglas 9ac253b
fix
dunglas 47bf7fa
s/needing/needs/
dunglas 56fb717
add missing dash
dunglas b0911cc
better skipif
dunglas d9397d5
skip tests if libcurl < 8.1.0
dunglas 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: Setup Caddy server | ||
runs: | ||
using: composite | ||
steps: | ||
- shell: bash | ||
run: | | ||
set -x | ||
sudo curl 'https://caddyserver.com/api/download?os=linux&arch=amd64' -o /usr/bin/caddy | ||
sudo chmod +x /usr/bin/caddy | ||
sudo caddy start --config ext/curl/tests/Caddyfile | ||
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,13 @@ | ||
{ | ||
admin off | ||
auto_https disable_redirects | ||
} | ||
|
||
localhost | ||
iluuu1994 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
respond / "Caddy is up and running" | ||
|
||
# HTTP/2 Server Push | ||
respond /serverpush "main response" | ||
respond /serverpush/pushed "pushed response" | ||
push /serverpush /serverpush/pushed |
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,62 @@ | ||
--TEST-- | ||
Test CURLMOPT_PUSHFUNCTION | ||
--CREDITS-- | ||
Davey Shafik | ||
Kévin Dunglas | ||
--EXTENSIONS-- | ||
curl | ||
--SKIPIF-- | ||
<?php | ||
include 'skipif-nocaddy.inc'; | ||
|
||
$curl_version = curl_version(); | ||
if ($curl_version['version_number'] < 0x080100) { | ||
exit("skip: test may crash with curl < 8.1.0"); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
$callback = function($parent_ch, $pushed_ch, array $headers) { | ||
return CURL_PUSH_OK; | ||
}; | ||
|
||
$mh = curl_multi_init(); | ||
|
||
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); | ||
curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback); | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, "https://localhost/serverpush"); | ||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
|
||
curl_multi_add_handle($mh, $ch); | ||
|
||
$responses = []; | ||
$active = null; | ||
do { | ||
$status = curl_multi_exec($mh, $active); | ||
|
||
do { | ||
$info = curl_multi_info_read($mh); | ||
if (false !== $info && $info['msg'] == CURLMSG_DONE) { | ||
$handle = $info['handle']; | ||
if ($handle !== null) { | ||
$responses[] = curl_multi_getcontent($info['handle']); | ||
curl_multi_remove_handle($mh, $handle); | ||
curl_close($handle); | ||
} | ||
} | ||
} while ($info); | ||
} while (count($responses) !== 2); | ||
|
||
curl_multi_close($mh); | ||
|
||
sort($responses); | ||
print_r($responses); | ||
--EXPECT-- | ||
Array | ||
( | ||
[0] => main response | ||
[1] => pushed response | ||
) |
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,12 @@ | ||
<?php | ||
|
||
$ch = curl_init("https://localhost"); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
|
||
$body = curl_exec($ch); | ||
|
||
curl_close($ch); | ||
|
||
if ($body !== "Caddy is up and running") { | ||
die("skip test needs Caddy"); | ||
} |
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.