From 4c4b14020d4446db8ccf425fae0d7927e2a6e8f0 Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 27 Dec 2023 18:10:17 +0800 Subject: [PATCH] fix http client cookie --- var/Typecho/Http/Client.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/var/Typecho/Http/Client.php b/var/Typecho/Http/Client.php index 858db027..9448f215 100644 --- a/var/Typecho/Http/Client.php +++ b/var/Typecho/Http/Client.php @@ -39,13 +39,6 @@ class Client */ private string $query; - /** - * User Agent - * - * @var string - */ - private string $agent; - /** * 设置超时 * @@ -116,6 +109,7 @@ class Client public function setCookie(string $key, $value): Client { $this->cookies[$key] = $value; + $this->setHeader('Cookie', str_replace('&', '; ', http_build_query($this->cookies))); return $this; } @@ -304,10 +298,6 @@ class Client $headers[] = $key . ': ' . $val; } - if (!empty($this->cookies)) { - $headers[] = 'Cookie: ' . str_replace('&', '; ', http_build_query($this->cookies)); - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); }