Skip to content

Commit 7fe103f

Browse files
committed
saved cookies file path as a static variable
1 parent 8c381f2 commit 7fe103f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/RequestResolvers/Curl.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class Curl implements RequestResolverInterface
88
{
9+
protected static $tmpCookies;
910
protected $isBinary;
1011
protected $result;
1112
protected $content;
@@ -109,16 +110,18 @@ protected function resolve()
109110
$this->content = '';
110111
$this->isBinary = null;
111112

112-
$tmpCookies = str_replace('//', '/', sys_get_temp_dir().'/embed-cookies.txt');
113+
if (!self::$tmpCookies) {
114+
self::$tmpCookies = str_replace('//', '/', sys_get_temp_dir().'/embed-cookies.txt');
115+
}
113116

114117
$connection = curl_init();
115118

116119
curl_setopt_array($connection, [
117120
CURLOPT_RETURNTRANSFER => false,
118121
CURLOPT_FOLLOWLOCATION => true,
119122
CURLOPT_URL => $this->url,
120-
CURLOPT_COOKIEJAR => $tmpCookies,
121-
CURLOPT_COOKIEFILE => $tmpCookies,
123+
CURLOPT_COOKIEJAR => self::$tmpCookies,
124+
CURLOPT_COOKIEFILE => self::$tmpCookies,
122125
CURLOPT_HEADERFUNCTION => [$this, 'headerCallback'],
123126
CURLOPT_WRITEFUNCTION => [$this, 'writeCallback'],
124127
] + $this->config);

0 commit comments

Comments
 (0)