Skip to content

Commit 30a80b8

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: tests(ext-curl): fix HTTP/2 Server Push tests
2 parents ca661f2 + 47d4788 commit 30a80b8

File tree

7 files changed

+110
-18
lines changed

7 files changed

+110
-18
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Setup Caddy server
2+
runs:
3+
using: composite
4+
steps:
5+
- shell: bash
6+
run: |
7+
set -x
8+
sudo curl 'https://caddyserver.com/api/download?os=linux&arch=amd64' -o /usr/bin/caddy
9+
sudo chmod +x /usr/bin/caddy
10+
sudo caddy start --config ext/curl/tests/Caddyfile

.github/workflows/push.yml

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
uses: ./.github/actions/setup-mssql
4444
- name: Create Oracle container
4545
uses: ./.github/actions/setup-oracle
46+
- name: Setup Caddy server
47+
uses: ./.github/actions/setup-caddy
4648
- name: apt
4749
uses: ./.github/actions/apt-x64
4850
- name: ccache

ext/curl/tests/Caddyfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
admin off
3+
auto_https disable_redirects
4+
}
5+
6+
localhost
7+
8+
respond / "Caddy is up and running"
9+
10+
# HTTP/2 Server Push
11+
respond /serverpush "main response"
12+
respond /serverpush/pushed "pushed response"
13+
push /serverpush /serverpush/pushed

ext/curl/tests/bug76675.phpt

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22
Bug #76675 (Segfault with H2 server push write/writeheader handlers)
33
--EXTENSIONS--
44
curl
5-
--XFAIL--
6-
http2.golang.org/serverpush is gone
75
--SKIPIF--
86
<?php
9-
if (getenv("SKIP_ONLINE_TESTS")) {
10-
die("skip online test");
11-
}
7+
include 'skipif-nocaddy.inc';
8+
129
$curl_version = curl_version();
13-
if ($curl_version['version_number'] < 0x073d00) {
14-
exit("skip: test may crash with curl < 7.61.0");
10+
if ($curl_version['version_number'] < 0x080100) {
11+
exit("skip: test may crash with curl < 8.1.0");
1512
}
16-
die("skip test is slow due to timeout, and XFAILs anyway");
1713
?>
1814
--FILE--
1915
<?php
@@ -30,7 +26,7 @@ $mh = curl_multi_init();
3026
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
3127
curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback);
3228
$ch = curl_init();
33-
curl_setopt($ch, CURLOPT_URL, 'https://http2.golang.org/serverpush');
29+
curl_setopt($ch, CURLOPT_URL, 'https://localhost/serverpush');
3430
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
3531
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
3632
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

ext/curl/tests/bug77535.phpt

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22
Bug #77535 (Invalid callback, h2 server push)
33
--EXTENSIONS--
44
curl
5-
--XFAIL--
6-
http2.golang.org/serverpush is gone
75
--SKIPIF--
86
<?php
9-
if (getenv("SKIP_ONLINE_TESTS")) {
10-
die("skip online test");
11-
}
7+
include 'skipif-nocaddy.inc';
8+
129
$curl_version = curl_version();
13-
if ($curl_version['version_number'] < 0x073d00) {
14-
exit("skip: test may crash with curl < 7.61.0");
10+
if ($curl_version['version_number'] < 0x080100) {
11+
exit("skip: test may crash with curl < 8.1.0");
1512
}
16-
die("skip test is slow due to timeout, and XFAILs anyway");
1713
?>
1814
--FILE--
1915
<?php
@@ -36,7 +32,7 @@ class MyHttpClient
3632
curl_setopt($this->curl, CURLOPT_HEADER, false);
3733
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, false);
3834
curl_setopt($this->curl, CURLOPT_FAILONERROR, false);
39-
curl_setopt($this->curl, CURLOPT_URL, 'https://http2.golang.org/serverpush');
35+
curl_setopt($this->curl, CURLOPT_URL, 'https://localhost/serverpush');
4036
curl_setopt($this->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
4137
curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, function ($ch, $data) {
4238
return \strlen($data);

ext/curl/tests/curl_pushfunction.phpt

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--TEST--
2+
Test CURLMOPT_PUSHFUNCTION
3+
--CREDITS--
4+
Davey Shafik
5+
Kévin Dunglas
6+
--EXTENSIONS--
7+
curl
8+
--SKIPIF--
9+
<?php
10+
include 'skipif-nocaddy.inc';
11+
12+
$curl_version = curl_version();
13+
if ($curl_version['version_number'] < 0x080100) {
14+
exit("skip: test may crash with curl < 8.1.0");
15+
}
16+
?>
17+
--FILE--
18+
<?php
19+
$callback = function($parent_ch, $pushed_ch, array $headers) {
20+
return CURL_PUSH_OK;
21+
};
22+
23+
$mh = curl_multi_init();
24+
25+
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
26+
curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback);
27+
28+
$ch = curl_init();
29+
curl_setopt($ch, CURLOPT_URL, "https://localhost/serverpush");
30+
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
31+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
32+
33+
curl_multi_add_handle($mh, $ch);
34+
35+
$responses = [];
36+
$active = null;
37+
do {
38+
$status = curl_multi_exec($mh, $active);
39+
40+
do {
41+
$info = curl_multi_info_read($mh);
42+
if (false !== $info && $info['msg'] == CURLMSG_DONE) {
43+
$handle = $info['handle'];
44+
if ($handle !== null) {
45+
$responses[] = curl_multi_getcontent($info['handle']);
46+
curl_multi_remove_handle($mh, $handle);
47+
curl_close($handle);
48+
}
49+
}
50+
} while ($info);
51+
} while (count($responses) !== 2);
52+
53+
curl_multi_close($mh);
54+
55+
sort($responses);
56+
print_r($responses);
57+
?>
58+
--EXPECT--
59+
Array
60+
(
61+
[0] => main response
62+
[1] => pushed response
63+
)

ext/curl/tests/skipif-nocaddy.inc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
$ch = curl_init("https://localhost");
4+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
5+
6+
$body = curl_exec($ch);
7+
8+
curl_close($ch);
9+
10+
if ($body !== "Caddy is up and running") {
11+
die("skip test needs Caddy");
12+
}

0 commit comments

Comments
 (0)