Skip to content

Commit

Permalink
Force IPv4 resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe committed Nov 16, 2020
1 parent 9c2fc84 commit 0beae7e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/HttpClient/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ public function request($method, $absUrl, $headers, $params, $hasFile)
$opts[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_2TLS;
}

// Stripe's API servers are only accessible over IPv4. Force IPv4 resolving to avoid
// potential issues (cf. https://github.com/stripe/stripe-php/issues/1045).
$opts[\CURLOPT_IPRESOLVE] = \CURL_IPRESOLVE_V4;

list($rbody, $rcode, $rheaders) = $this->executeRequestWithRetries($opts, $absUrl);

return [$rbody, $rcode, $rheaders];
Expand All @@ -283,7 +287,6 @@ public function request($method, $absUrl, $headers, $params, $hasFile)
private function executeRequestWithRetries($opts, $absUrl)
{
$numRetries = 0;
$isPost = \array_key_exists(\CURLOPT_POST, $opts) && 1 === $opts[\CURLOPT_POST];

while (true) {
$rcode = 0;
Expand Down

0 comments on commit 0beae7e

Please sign in to comment.