Skip to content

Commit

Permalink
[PHP 8.4] Add CURL_HTTP_VERSION_3(ONLY) constants
Browse files Browse the repository at this point in the history
If the underlying Curl build supports it, setting the HTTP version
should be theoretically possible. The availability of the constants
do not guarantee the feature support, so declaring them in the
polyfill should be same and effective.

 - PR that added constants: [php-src#15350](php/php-src#15350)
 - libcurl doc on `CURLOPT_HTTP_VERSION`](https://curl.se/libcurl/c/CURLOPT_HTTP_VERSION.html)
 - [PHP.Watch: HTTP/3 Request with PHP Curl Extension](https://php.watch/articles/php-curl-http3)
 - Codex for [`CURL_HTTP_VERSION_3`](https://php.watch/codex/CURL_HTTP_VERSION_3) and [`CURL_HTTP_VERSION_3ONLY`](https://php.watch/codex/CURL_HTTP_VERSION_3ONLY)

Fixes GH-488.
  • Loading branch information
Ayesh authored and nicolas-grekas committed Sep 9, 2024
1 parent 3e6c61a commit a02f8fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This component provides features added to PHP 8.4 core:
- [`mb_ucfirst` and `mb_lcfirst`](https://wiki.php.net/rfc/mb_ucfirst)
- [`array_find`, `array_find_key`, `array_any` and `array_all`](https://wiki.php.net/rfc/array_find)
- [`Deprecated`](https://wiki.php.net/rfc/deprecated_attribute)
- `CURL_HTTP_VERSION_3` and `CURL_HTTP_VERSION_3ONLY` constants

More information can be found in the
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
Expand Down
8 changes: 8 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
return;
}

if (defined('CURL_VERSION_HTTP3') || PHP_VERSION_ID < 80200 && function_exists('curl_version') && curl_version()['version'] >= 0x074200) { // libcurl >= 7.66.0
define('CURL_HTTP_VERSION_3', 30);

if (defined('CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256')) { // libcurl >= 7.80.0 (7.88 would be better but is slow to check)
define('CURL_HTTP_VERSION_3ONLY', 31);
}
}

if (!function_exists('array_find')) {
function array_find(array $array, callable $callback) { return p\Php84::array_find($array, $callback); }
}
Expand Down

0 comments on commit a02f8fc

Please sign in to comment.