Skip to content

Commit 7fc2857

Browse files
committed
Improve CurlHttpClient
1 parent 4179375 commit 7fc2857

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/CurlHttpClient.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function __construct(array $options = [])
4343
CURLOPT_FAILONERROR => true,
4444
CURLOPT_FOLLOWLOCATION => true,
4545
CURLOPT_RETURNTRANSFER => true,
46+
CURLOPT_SSL_VERIFYPEER => false,
4647
CURLOPT_HTTPGET => true,
4748
];
4849

@@ -59,18 +60,16 @@ public function __construct(array $options = [])
5960
*/
6061
public function getContent(string $url): string
6162
{
62-
$options = $this->options;
63-
$options[CURLOPT_URL] = $url;
64-
$curl = curl_init();
65-
curl_setopt_array($curl, $options);
63+
$curl = curl_init($url);
64+
curl_setopt_array($curl, $this->options);
6665
$content = curl_exec($curl);
67-
$code = curl_errno($curl);
68-
$message = curl_error($curl);
66+
$error_code = curl_errno($curl);
67+
$error_message = curl_error($curl);
6968
curl_close($curl);
70-
if (CURLE_OK === $code) {
69+
if (CURLE_OK === $error_code) {
7170
return $content;
7271
}
7372

74-
throw new HttpClientException($message, $code);
73+
throw new HttpClientException($error_message, $error_code);
7574
}
7675
}

0 commit comments

Comments
 (0)