Skip to content

Commit

Permalink
修复新版 libcurl 兼容问题 (#27)
Browse files Browse the repository at this point in the history
* 修复新版 libcurl 兼容问题

* 新增 Swoole v5.1 测试
  • Loading branch information
Yurunsoft authored Oct 16, 2023
1 parent 73e8018 commit 427d17c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
matrix:
swoole:
[
5.1-php8.0,
5.1-php8.1,
5.1-php8.2,
5.0-php8.0,
5.0-php8.1,
5.0-php8.2,
Expand Down
16 changes: 7 additions & 9 deletions src/YurunHttp/Handler/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,6 @@ private function buildCurlHandlerBase(&$request, $handler, &$headers = null, &$s
{
$options[\CURLOPT_RETURNTRANSFER] = true;
}
// 保存cookie
if (!isset($options[\CURLOPT_COOKIEJAR]))
{
$options[\CURLOPT_COOKIEJAR] = 'php://memory';
}
// 允许复用连接
if (!isset($options[\CURLOPT_FORBID_REUSE]))
{
Expand All @@ -323,7 +318,6 @@ private function buildCurlHandlerBase(&$request, $handler, &$headers = null, &$s
$this->parseSSL($request, $options);
$this->parseProxy($request, $options);
$this->parseHeaders($request, $options);
$this->parseCookies($request, $options);
$this->parseNetwork($request, $options);
curl_setopt_array($handler, $options);
}
Expand Down Expand Up @@ -386,6 +380,7 @@ private function buildCurlHandlerEx(&$request, $handler, $uri = null, $method =
{
$requestOptions[\CURLOPT_NOBODY] = true;
}
$this->parseCookies($request, $requestOptions);
curl_setopt_array($handler, $requestOptions);
}

Expand Down Expand Up @@ -677,7 +672,7 @@ private function parseNetwork(&$request, &$options)
}
else
{
$userPwd = '';
$userPwd = null;
}
// 连接超时
$options[\CURLOPT_CONNECTTIMEOUT_MS] = $request->getAttribute(Attributes::CONNECT_TIMEOUT, 30000);
Expand All @@ -687,8 +682,11 @@ private function parseNetwork(&$request, &$options)
$options[\CURLOPT_MAX_RECV_SPEED_LARGE] = $request->getAttribute(Attributes::DOWNLOAD_SPEED);
// 上传限速
$options[\CURLOPT_MAX_SEND_SPEED_LARGE] = $request->getAttribute(Attributes::UPLOAD_SPEED);
// 连接中用到的用户名和密码
$options[\CURLOPT_USERPWD] = $userPwd;
if (null !== $userPwd)
{
// 连接中用到的用户名和密码
$options[\CURLOPT_USERPWD] = $userPwd;
}
}

/**
Expand Down

0 comments on commit 427d17c

Please sign in to comment.