Skip to content

Commit f75ab9f

Browse files
authored
Merge pull request #743 from crazywhalecc/feat/h3
Feature: add http/3 support to curl.
2 parents 856db3d + 8e5efb9 commit f75ab9f

File tree

16 files changed

+310
-4
lines changed

16 files changed

+310
-4
lines changed

config/lib.json

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
"libssh2",
8787
"brotli",
8888
"nghttp2",
89+
"nghttp3",
90+
"ngtcp2",
8991
"zstd",
9092
"libcares"
9193
],
@@ -615,7 +617,44 @@
615617
"openssl"
616618
],
617619
"lib-suggests": [
618-
"libxml2"
620+
"libxml2",
621+
"nghttp3",
622+
"ngtcp2"
623+
]
624+
},
625+
"nghttp3": {
626+
"source": "nghttp3",
627+
"static-libs-unix": [
628+
"libnghttp3.a"
629+
],
630+
"static-libs-windows": [
631+
"nghttp3.lib"
632+
],
633+
"headers": [
634+
"nghttp3"
635+
],
636+
"lib-depends": [
637+
"openssl"
638+
],
639+
"lib-suggests": [
640+
"ngtcp2"
641+
]
642+
},
643+
"ngtcp2": {
644+
"source": "ngtcp2",
645+
"static-libs-unix": [
646+
"libngtcp2.a",
647+
"libngtcp2_crypto_ossl.a"
648+
],
649+
"static-libs-windows": [
650+
"ngtcp2.lib",
651+
"ngtcp2_crypto_ossl.lib"
652+
],
653+
"headers": [
654+
"ngtcp2"
655+
],
656+
"lib-depends": [
657+
"openssl"
619658
]
620659
},
621660
"onig": {

config/source.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,26 @@
714714
"path": "COPYING"
715715
}
716716
},
717+
"nghttp3": {
718+
"type": "ghrel",
719+
"repo": "ngtcp2/nghttp3",
720+
"match": "nghttp3.+\\.tar\\.xz",
721+
"prefer-stable": true,
722+
"license": {
723+
"type": "file",
724+
"path": "COPYING"
725+
}
726+
},
727+
"ngtcp2": {
728+
"type": "ghrel",
729+
"repo": "ngtcp2/ngtcp2",
730+
"match": "ngtcp2.+\\.tar\\.xz",
731+
"prefer-stable": true,
732+
"license": {
733+
"type": "file",
734+
"path": "COPYING"
735+
}
736+
},
717737
"onig": {
718738
"type": "ghrel",
719739
"repo": "kkos/oniguruma",

docs/en/guide/extension-notes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ which will be listed one by one here.
66

77
## curl
88

9+
HTTP3 support is not enabled by default, compile with `--with-libs="nghttp2,nghttp3,ngtcp2"` to enable HTTP3 support for PHP >= 8.4.
10+
911
When using curl to request HTTPS, there may be an `error:80000002:system library::No such file or directory` error.
1012
For details on the solution, see [FAQ - Unable to use ssl](../faq/#unable-to-use-ssl).
1113

@@ -156,4 +158,4 @@ Parallel is only supported on PHP 8.0 ZTS and above.
156158

157159
1. This is not technically an extension, but a library.
158160
2. Building with `--with-libs="mimalloc"` on Linux or macOS will override the default allocator.
159-
3. This is experimental for now, but is recommended in threaded environments.
161+
3. This is experimental for now, but is recommended in threaded environments.

docs/zh/guide/extension-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## curl
66

7+
HTTP3 支持默认未启用,需在编译时添加 `--with-libs="nghttp2,nghttp3,ngtcp2"` 以启用 PHP 8.4 及以上版本的 HTTP3 支持。
8+
79
使用 curl 请求 HTTPS 时,可能存在 `error:80000002:system library::No such file or directory` 错误,
810
解决办法详见 [FAQ - 无法使用 ssl](../faq/#无法使用-ssl)
911

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public function makeAutoconfArgs(string $name, array $libSpecs): string
8080
$ret = '';
8181
foreach ($libSpecs as $libName => $arr) {
8282
$lib = $this->getLib($libName);
83+
if ($lib === null && str_starts_with($libName, 'lib')) {
84+
$lib = $this->getExt(substr($libName, 3));
85+
}
8386

8487
$arr = $arr ?? [];
8588

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class nghttp3 extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\nghttp3;
10+
11+
public const NAME = 'nghttp3';
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class ngtcp2 extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\ngtcp2;
10+
11+
public const NAME = 'ngtcp2';
12+
}

src/SPC/builder/macos/MacOSBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public function makeAutoconfArgs(string $name, array $lib_specs): string
5555
$ret = '';
5656
foreach ($lib_specs as $libName => $arr) {
5757
$lib = $this->getLib($libName);
58+
if ($lib === null && str_starts_with($libName, 'lib')) {
59+
$lib = $this->getExt(substr($libName, 3));
60+
}
5861

5962
$arr = $arr ?? [];
6063

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
class nghttp3 extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\nghttp3;
10+
11+
public const NAME = 'nghttp3';
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
class ngtcp2 extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\ngtcp2;
10+
11+
public const NAME = 'ngtcp2';
12+
}

0 commit comments

Comments
 (0)