Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit e2dc662

Browse files
author
Fosco Marotto
committed
Added a method to disable IPv6 resolution.
1 parent 9ff0b14 commit e2dc662

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Facebook/HttpClients/FacebookCurlHttpClient.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class FacebookCurlHttpClient implements FacebookHttpable
6767
*/
6868
protected static $facebookCurl;
6969

70+
/**
71+
* @var boolean If IPv6 should be disabled
72+
*/
73+
protected static $disableIPv6;
74+
7075
/**
7176
* @const Curl Version which is unaffected by the proxy header length error.
7277
*/
@@ -83,6 +88,15 @@ class FacebookCurlHttpClient implements FacebookHttpable
8388
public function __construct(FacebookCurl $facebookCurl = null)
8489
{
8590
self::$facebookCurl = $facebookCurl ?: new FacebookCurl();
91+
self::$disableIPv6 = self::$disableIPv6 ?: false;
92+
}
93+
94+
/**
95+
* Disable IPv6 resolution
96+
*/
97+
public function disableIPv6()
98+
{
99+
self::$disableIPv6 = true;
86100
}
87101

88102
/**
@@ -180,6 +194,10 @@ public function openConnection($url, $method = 'GET', $parameters = array())
180194
$options[CURLOPT_HTTPHEADER] = $this->compileRequestHeaders();
181195
}
182196

197+
if (self::$disableIPv6) {
198+
$options[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
199+
}
200+
183201
self::$facebookCurl->init();
184202
self::$facebookCurl->setopt_array($options);
185203
}

0 commit comments

Comments
 (0)