Skip to content

Commit

Permalink
修复测试
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Oct 16, 2023
1 parent b8915fe commit 327db5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/YurunHttp/Handler/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ 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_COOKIEJAR]))
// {
// $options[\CURLOPT_COOKIEJAR] = 'php://memory';
// }
// 允许复用连接
if (!isset($options[\CURLOPT_FORBID_REUSE]))
{
Expand All @@ -324,7 +324,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 @@ -387,6 +386,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 @@ -649,9 +649,11 @@ private function parseHeadersFormat($request)
private function parseCookies(&$request, &$options)
{
$cookieManager = $this->cookieManager;
$cookie = [];
foreach ($request->getCookieParams() as $name => $value)
{
$cookieManager->setCookie($name, $value);
$cookie[] = $name . '=' . $value;
}
$cookie = $cookieManager->getRequestCookieString($request->getUri());
if ('' !== $cookie)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/HttpRequestTest/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@ public function testBug19(): void
{
$this->call(function () {
$http = new HttpRequest();
$response = $http->head('https://www.bing.com');
$response = $http->head('https://www.baidu.com');
$this->assertResponse($response);
$response = $http->get('https://www.bing.com');
$response = $http->get('https://www.baidu.com');
$this->assertResponse($response);
$this->assertTrue('' != $response->body());
});
Expand Down

0 comments on commit 327db5a

Please sign in to comment.