Skip to content

Commit

Permalink
Add curl_reset and remove CURLOPT_HTTP_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrikmoe committed Oct 30, 2023
1 parent 94469cc commit 9d2ee0e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/Scanpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,16 @@ private function request(string $path, array $opts = [], array $data = null): ar

$curlopts = [
CURLOPT_URL => 'https://' . ($opts['hostname'] ?? 'api.scanpay.dk') . $path,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array_values($headers),
CURLOPT_VERBOSE => $opts['debug'] ?? 0,
CURLOPT_TCP_KEEPALIVE => 1, // TODO: CURLOPT_TCP_KEEPINTVL & CURLOPT_TCP_KEEPIDLE
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CONNECTTIMEOUT => 20,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2TLS,
CURLOPT_TIMEOUT => 120,
CURLOPT_DNS_CACHE_TIMEOUT => 180,
//CURLOPT_DNS_SHUFFLE_ADDRESSES => 1,
];
if (isset($data)) {
$curlopts[CURLOPT_CUSTOMREQUEST] = 'POST';
$curlopts[CURLOPT_POSTFIELDS] = json_encode($data, JSON_UNESCAPED_SLASHES);
if ($curlopts[CURLOPT_POSTFIELDS] === false) {
throw new \Exception('Failed to JSON encode request to Scanpay: ' . json_last_error_msg());
Expand All @@ -83,6 +80,7 @@ private function request(string $path, array $opts = [], array $data = null): ar
$curlopts[$key] = $val;
}
}
curl_reset($this->ch);
curl_setopt_array($this->ch, $curlopts);
$result = curl_exec($this->ch);
if ($result === false) {
Expand Down

0 comments on commit 9d2ee0e

Please sign in to comment.