Skip to content

Commit 82d3cda

Browse files
committed
修复
1 parent 11f8a50 commit 82d3cda

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
run: |
8181
sudo apt-get update
8282
sudo apt-get install -y build-essential autoconf libtool pkg-config \
83-
cmake ninja-build libssl-dev libpsl-dev libnghttp2-dev git
83+
cmake ninja-build libgnutls28-dev libpsl-dev libnghttp2-dev git
8484
8585
# 发行版自带 libcurl 未编译 QUIC,这里从源码构建带 HTTP/3 的 curl
8686
- name: Build curl with HTTP/3 (ngtcp2 + nghttp3)
@@ -102,15 +102,15 @@ jobs:
102102
cd ngtcp2
103103
git submodule update --init
104104
autoreconf -fi
105-
./configure --prefix=$PREFIX --enable-lib-only
105+
./configure --prefix=$PREFIX --enable-lib-only --with-gnutls
106106
make -j"$(nproc)"
107107
sudo make install
108108
cd ..
109109
110110
git clone --depth 1 --branch curl-8_10_1 https://github.com/curl/curl.git
111111
cd curl
112112
autoreconf -fi
113-
./configure --prefix=$PREFIX --with-openssl --with-nghttp2 \
113+
./configure --prefix=$PREFIX --with-gnutls --with-nghttp2 \
114114
--with-nghttp3 --with-ngtcp2
115115
make -j"$(nproc)"
116116
sudo make install

‎src/YurunHttp/Handler/Curl.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,9 @@ private function getResponse($request, $handler, $body, $receiveHeaders)
423423
// body
424424
$result = new Response($body, curl_getinfo($handler, \CURLINFO_HTTP_CODE));
425425

426-
// 实际使用的 HTTP 协议版本
427-
$httpVersion = $this->getCurlHttpVersion(curl_getinfo($handler, \CURLINFO_HTTP_VERSION));
428-
426+
// 实际使用的 HTTP 协议版本(CURLINFO_HTTP_VERSION 自 PHP 7.3 引入)
427+
$curlHttpVersion = \defined('\CURLINFO_HTTP_VERSION') ? curl_getinfo($handler, \CURLINFO_HTTP_VERSION) : 0;
428+
$httpVersion = $this->getCurlHttpVersion($curlHttpVersion);
429429

430430
// headers
431431
$headers = $this->parseHeaderOneRequest($receiveHeaders);
@@ -467,11 +467,11 @@ private function getCurlHttpVersion($version)
467467
{
468468
switch ($version)
469469
{
470-
case \CURL_HTTP_VERSION_1_0:
470+
case \defined('\CURL_HTTP_VERSION_1_0') ? \CURL_HTTP_VERSION_1_0 : 1:
471471
return '1.0';
472-
case \CURL_HTTP_VERSION_1_1:
472+
case \defined('\CURL_HTTP_VERSION_1_1') ? \CURL_HTTP_VERSION_1_1 : 2:
473473
return '1.1';
474-
case \CURL_HTTP_VERSION_2:
474+
case \defined('\CURL_HTTP_VERSION_2') ? \CURL_HTTP_VERSION_2 : 3:
475475
return '2.0';
476476
case \defined('\CURL_HTTP_VERSION_3') ? \CURL_HTTP_VERSION_3 : 30:
477477
return '3.0';

0 commit comments

Comments
 (0)