Skip to content

Commit

Permalink
Force IPv4 resolving (#1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe authored Nov 16, 2020
1 parent 9c2fc84 commit 033e783
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 033e783

Please sign in to comment.