tests(ext-curl): fix HTTP/2 Server Push tests
Closes GH-10669
This commit is contained in:

committed by
Ilija Tovilo

parent
824d1f95ad
commit
47d478806a
10
.github/actions/setup-caddy/action.yml
vendored
Normal file
10
.github/actions/setup-caddy/action.yml
vendored
Normal file
@ -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
|
2
.github/workflows/push.yml
vendored
2
.github/workflows/push.yml
vendored
@ -42,6 +42,8 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-mssql
|
uses: ./.github/actions/setup-mssql
|
||||||
- name: Create Oracle container
|
- name: Create Oracle container
|
||||||
uses: ./.github/actions/setup-oracle
|
uses: ./.github/actions/setup-oracle
|
||||||
|
- name: Setup Caddy server
|
||||||
|
uses: ./.github/actions/setup-caddy
|
||||||
- name: apt
|
- name: apt
|
||||||
uses: ./.github/actions/apt-x64
|
uses: ./.github/actions/apt-x64
|
||||||
- name: ccache
|
- name: ccache
|
||||||
|
13
ext/curl/tests/Caddyfile
Normal file
13
ext/curl/tests/Caddyfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
admin off
|
||||||
|
auto_https disable_redirects
|
||||||
|
}
|
||||||
|
|
||||||
|
localhost
|
||||||
|
|
||||||
|
respond / "Caddy is up and running"
|
||||||
|
|
||||||
|
# HTTP/2 Server Push
|
||||||
|
respond /serverpush "main response"
|
||||||
|
respond /serverpush/pushed "pushed response"
|
||||||
|
push /serverpush /serverpush/pushed
|
@ -2,18 +2,14 @@
|
|||||||
Bug #76675 (Segfault with H2 server push write/writeheader handlers)
|
Bug #76675 (Segfault with H2 server push write/writeheader handlers)
|
||||||
--EXTENSIONS--
|
--EXTENSIONS--
|
||||||
curl
|
curl
|
||||||
--XFAIL--
|
|
||||||
http2.golang.org/serverpush is gone
|
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
if (getenv("SKIP_ONLINE_TESTS")) {
|
include 'skipif-nocaddy.inc';
|
||||||
die("skip online test");
|
|
||||||
}
|
|
||||||
$curl_version = curl_version();
|
$curl_version = curl_version();
|
||||||
if ($curl_version['version_number'] < 0x073d00) {
|
if ($curl_version['version_number'] < 0x080100) {
|
||||||
exit("skip: test may crash with curl < 7.61.0");
|
exit("skip: test may crash with curl < 8.1.0");
|
||||||
}
|
}
|
||||||
die("skip test is slow due to timeout, and XFAILs anyway");
|
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
@ -30,7 +26,7 @@ $mh = curl_multi_init();
|
|||||||
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
|
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
|
||||||
curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback);
|
curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback);
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, 'https://http2.golang.org/serverpush');
|
curl_setopt($ch, CURLOPT_URL, 'https://localhost/serverpush');
|
||||||
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
|
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
@ -2,18 +2,14 @@
|
|||||||
Bug #77535 (Invalid callback, h2 server push)
|
Bug #77535 (Invalid callback, h2 server push)
|
||||||
--EXTENSIONS--
|
--EXTENSIONS--
|
||||||
curl
|
curl
|
||||||
--XFAIL--
|
|
||||||
http2.golang.org/serverpush is gone
|
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
if (getenv("SKIP_ONLINE_TESTS")) {
|
include 'skipif-nocaddy.inc';
|
||||||
die("skip online test");
|
|
||||||
}
|
|
||||||
$curl_version = curl_version();
|
$curl_version = curl_version();
|
||||||
if ($curl_version['version_number'] < 0x073d00) {
|
if ($curl_version['version_number'] < 0x080100) {
|
||||||
exit("skip: test may crash with curl < 7.61.0");
|
exit("skip: test may crash with curl < 8.1.0");
|
||||||
}
|
}
|
||||||
die("skip test is slow due to timeout, and XFAILs anyway");
|
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
@ -36,7 +32,7 @@ class MyHttpClient
|
|||||||
curl_setopt($this->curl, CURLOPT_HEADER, false);
|
curl_setopt($this->curl, CURLOPT_HEADER, false);
|
||||||
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, false);
|
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, false);
|
||||||
curl_setopt($this->curl, CURLOPT_FAILONERROR, false);
|
curl_setopt($this->curl, CURLOPT_FAILONERROR, false);
|
||||||
curl_setopt($this->curl, CURLOPT_URL, 'https://http2.golang.org/serverpush');
|
curl_setopt($this->curl, CURLOPT_URL, 'https://localhost/serverpush');
|
||||||
curl_setopt($this->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
|
curl_setopt($this->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
|
||||||
curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, function ($ch, $data) {
|
curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, function ($ch, $data) {
|
||||||
return \strlen($data);
|
return \strlen($data);
|
||||||
|
63
ext/curl/tests/curl_pushfunction.phpt
Normal file
63
ext/curl/tests/curl_pushfunction.phpt
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
--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
|
||||||
|
)
|
12
ext/curl/tests/skipif-nocaddy.inc
Normal file
12
ext/curl/tests/skipif-nocaddy.inc
Normal file
@ -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");
|
||||||
|
}
|
Reference in New Issue
Block a user