summaryrefslogtreecommitdiff
path: root/lib/facebook-graph-sdk/src/Facebook/HttpClients
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facebook-graph-sdk/src/Facebook/HttpClients')
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurl.php129
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php210
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookGuzzleHttpClient.php97
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookHttpClientInterface.php47
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookStream.php80
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookStreamHttpClient.php94
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/HttpClients/certs/DigiCertHighAssuranceEVRootCA.pem23
7 files changed, 680 insertions, 0 deletions
diff --git a/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurl.php b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurl.php
new file mode 100644
index 0000000..e5d124a
--- /dev/null
+++ b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurl.php
@@ -0,0 +1,129 @@
+<?php
+/**
+ * Copyright 2014 Facebook, Inc.
+ *
+ * You are hereby granted a non-exclusive, worldwide, royalty-free license to
+ * use, copy, modify, and distribute this software in source code or binary
+ * form for use in connection with the web services and APIs provided by
+ * Facebook.
+ *
+ * As with any software that integrates with the Facebook platform, your use
+ * of this software is subject to the Facebook Developer Principles and
+ * Policies [http://developers.facebook.com/policy/]. This copyright notice
+ * shall be included in all copies or substantial portions of the software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+namespace Facebook\HttpClients;
+
+/**
+ * Class FacebookCurl
+ *
+ * Abstraction for the procedural curl elements so that curl can be mocked and the implementation can be tested.
+ *
+ * @package Facebook
+ */
+class FacebookCurl
+{
+
+ /**
+ * @var resource Curl resource instance
+ */
+ protected $curl;
+
+ /**
+ * Make a new curl reference instance
+ */
+ public function init()
+ {
+ $this->curl = curl_init();
+ }
+
+ /**
+ * Set a curl option
+ *
+ * @param $key
+ * @param $value
+ */
+ public function setopt($key, $value)
+ {
+ curl_setopt($this->curl, $key, $value);
+ }
+
+ /**
+ * Set an array of options to a curl resource
+ *
+ * @param array $options
+ */
+ public function setoptArray(array $options)
+ {
+ curl_setopt_array($this->curl, $options);
+ }
+
+ /**
+ * Send a curl request
+ *
+ * @return mixed
+ */
+ public function exec()
+ {
+ return curl_exec($this->curl);
+ }
+
+ /**
+ * Return the curl error number
+ *
+ * @return int
+ */
+ public function errno()
+ {
+ return curl_errno($this->curl);
+ }
+
+ /**
+ * Return the curl error message
+ *
+ * @return string
+ */
+ public function error()
+ {
+ return curl_error($this->curl);
+ }
+
+ /**
+ * Get info from a curl reference
+ *
+ * @param $type
+ *
+ * @return mixed
+ */
+ public function getinfo($type)
+ {
+ return curl_getinfo($this->curl, $type);
+ }
+
+ /**
+ * Get the currently installed curl version
+ *
+ * @return array
+ */
+ public function version()
+ {
+ return curl_version();
+ }
+
+ /**
+ * Close the resource connection to curl
+ */
+ public function close()
+ {
+ curl_close($this->curl);
+ }
+}
diff --git a/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php
new file mode 100644
index 0000000..955ac06
--- /dev/null
+++ b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php
@@ -0,0 +1,210 @@
+<?php
+/**
+ * Copyright 2014 Facebook, Inc.
+ *
+ * You are hereby granted a non-exclusive, worldwide, royalty-free license to
+ * use, copy, modify, and distribute this software in source code or binary
+ * form for use in connection with the web services and APIs provided by
+ * Facebook.
+ *
+ * As with any software that integrates with the Facebook platform, your use
+ * of this software is subject to the Facebook Developer Principles and
+ * Policies [http://developers.facebook.com/policy/]. This copyright notice
+ * shall be included in all copies or substantial portions of the software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+namespace Facebook\HttpClients;
+
+use Facebook\Http\GraphRawResponse;
+use Facebook\Exceptions\FacebookSDKException;
+
+/**
+ * Class FacebookCurlHttpClient
+ *
+ * @package Facebook
+ */
+class FacebookCurlHttpClient implements FacebookHttpClientInterface
+{
+ /**
+ * @var string The client error message
+ */
+ protected $curlErrorMessage = '';
+
+ /**
+ * @var int The curl client error code
+ */
+ protected $curlErrorCode = 0;
+
+ /**
+ * @var string|boolean The raw response from the server
+ */
+ protected $rawResponse;
+
+ /**
+ * @var FacebookCurl Procedural curl as object
+ */
+ protected $facebookCurl;
+
+ /**
+ * @const Curl Version which is unaffected by the proxy header length error.
+ */
+ const CURL_PROXY_QUIRK_VER = 0x071E00;
+
+ /**
+ * @const "Connection Established" header text
+ */
+ const CONNECTION_ESTABLISHED = "HTTP/1.0 200 Connection established\r\n\r\n";
+
+ /**
+ * @param FacebookCurl|null Procedural curl as object
+ */
+ public function __construct(FacebookCurl $facebookCurl = null)
+ {
+ $this->facebookCurl = $facebookCurl ?: new FacebookCurl();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function send($url, $method, $body, array $headers, $timeOut)
+ {
+ $this->openConnection($url, $method, $body, $headers, $timeOut);
+ $this->sendRequest();
+
+ if ($curlErrorCode = $this->facebookCurl->errno()) {
+ throw new FacebookSDKException($this->facebookCurl->error(), $curlErrorCode);
+ }
+
+ // Separate the raw headers from the raw body
+ list($rawHeaders, $rawBody) = $this->extractResponseHeadersAndBody();
+
+ $this->closeConnection();
+
+ return new GraphRawResponse($rawHeaders, $rawBody);
+ }
+
+ /**
+ * Opens a new curl connection.
+ *
+ * @param string $url The endpoint to send the request to.
+ * @param string $method The request method.
+ * @param string $body The body of the request.
+ * @param array $headers The request headers.
+ * @param int $timeOut The timeout in seconds for the request.
+ */
+ public function openConnection($url, $method, $body, array $headers, $timeOut)
+ {
+ $options = [
+ CURLOPT_CUSTOMREQUEST => $method,
+ CURLOPT_HTTPHEADER => $this->compileRequestHeaders($headers),
+ CURLOPT_URL => $url,
+ CURLOPT_CONNECTTIMEOUT => 10,
+ CURLOPT_TIMEOUT => $timeOut,
+ CURLOPT_RETURNTRANSFER => true, // Follow 301 redirects
+ CURLOPT_HEADER => true, // Enable header processing
+ CURLOPT_SSL_VERIFYHOST => 2,
+ CURLOPT_SSL_VERIFYPEER => true,
+ CURLOPT_CAINFO => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem',
+ ];
+
+ if ($method !== "GET") {
+ $options[CURLOPT_POSTFIELDS] = $body;
+ }
+
+ $this->facebookCurl->init();
+ $this->facebookCurl->setoptArray($options);
+ }
+
+ /**
+ * Closes an existing curl connection
+ */
+ public function closeConnection()
+ {
+ $this->facebookCurl->close();
+ }
+
+ /**
+ * Send the request and get the raw response from curl
+ */
+ public function sendRequest()
+ {
+ $this->rawResponse = $this->facebookCurl->exec();
+ }
+
+ /**
+ * Compiles the request headers into a curl-friendly format.
+ *
+ * @param array $headers The request headers.
+ *
+ * @return array
+ */
+ public function compileRequestHeaders(array $headers)
+ {
+ $return = [];
+
+ foreach ($headers as $key => $value) {
+ $return[] = $key . ': ' . $value;
+ }
+
+ return $return;
+ }
+
+ /**
+ * Extracts the headers and the body into a two-part array
+ *
+ * @return array
+ */
+ public function extractResponseHeadersAndBody()
+ {
+ $headerSize = $this->getHeaderSize();
+
+ $rawHeaders = mb_substr($this->rawResponse, 0, $headerSize);
+ $rawBody = mb_substr($this->rawResponse, $headerSize);
+
+ return [trim($rawHeaders), trim($rawBody)];
+ }
+
+ /**
+ * Return proper header size
+ *
+ * @return integer
+ */
+ private function getHeaderSize()
+ {
+ $headerSize = $this->facebookCurl->getinfo(CURLINFO_HEADER_SIZE);
+ // This corrects a Curl bug where header size does not account
+ // for additional Proxy headers.
+ if ($this->needsCurlProxyFix()) {
+ // Additional way to calculate the request body size.
+ if (preg_match('/Content-Length: (\d+)/', $this->rawResponse, $m)) {
+ $headerSize = mb_strlen($this->rawResponse) - $m[1];
+ } elseif (stripos($this->rawResponse, self::CONNECTION_ESTABLISHED) !== false) {
+ $headerSize += mb_strlen(self::CONNECTION_ESTABLISHED);
+ }
+ }
+
+ return $headerSize;
+ }
+
+ /**
+ * Detect versions of Curl which report incorrect header lengths when
+ * using Proxies.
+ *
+ * @return boolean
+ */
+ private function needsCurlProxyFix()
+ {
+ $ver = $this->facebookCurl->version();
+ $version = $ver['version_number'];
+
+ return $version < self::CURL_PROXY_QUIRK_VER;
+ }
+}
diff --git a/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookGuzzleHttpClient.php b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookGuzzleHttpClient.php
new file mode 100644
index 0000000..6f2a1c6
--- /dev/null
+++ b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookGuzzleHttpClient.php
@@ -0,0 +1,97 @@
+<?php
+/**
+ * Copyright 2014 Facebook, Inc.
+ *
+ * You are hereby granted a non-exclusive, worldwide, royalty-free license to
+ * use, copy, modify, and distribute this software in source code or binary
+ * form for use in connection with the web services and APIs provided by
+ * Facebook.
+ *
+ * As with any software that integrates with the Facebook platform, your use
+ * of this software is subject to the Facebook Developer Principles and
+ * Policies [http://developers.facebook.com/policy/]. This copyright notice
+ * shall be included in all copies or substantial portions of the software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+namespace Facebook\HttpClients;
+
+use Facebook\Http\GraphRawResponse;
+use Facebook\Exceptions\FacebookSDKException;
+
+use GuzzleHttp\Client;
+use GuzzleHttp\Message\ResponseInterface;
+use GuzzleHttp\Ring\Exception\RingException;
+use GuzzleHttp\Exception\RequestException;
+
+class FacebookGuzzleHttpClient implements FacebookHttpClientInterface
+{
+ /**
+ * @var \GuzzleHttp\Client The Guzzle client.
+ */
+ protected $guzzleClient;
+
+ /**
+ * @param \GuzzleHttp\Client|null The Guzzle client.
+ */
+ public function __construct(Client $guzzleClient = null)
+ {
+ $this->guzzleClient = $guzzleClient ?: new Client();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function send($url, $method, $body, array $headers, $timeOut)
+ {
+ $options = [
+ 'headers' => $headers,
+ 'body' => $body,
+ 'timeout' => $timeOut,
+ 'connect_timeout' => 10,
+ 'verify' => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem',
+ ];
+ $request = $this->guzzleClient->createRequest($method, $url, $options);
+
+ try {
+ $rawResponse = $this->guzzleClient->send($request);
+ } catch (RequestException $e) {
+ $rawResponse = $e->getResponse();
+
+ if ($e->getPrevious() instanceof RingException || !$rawResponse instanceof ResponseInterface) {
+ throw new FacebookSDKException($e->getMessage(), $e->getCode());
+ }
+ }
+
+ $rawHeaders = $this->getHeadersAsString($rawResponse);
+ $rawBody = $rawResponse->getBody();
+ $httpStatusCode = $rawResponse->getStatusCode();
+
+ return new GraphRawResponse($rawHeaders, $rawBody, $httpStatusCode);
+ }
+
+ /**
+ * Returns the Guzzle array of headers as a string.
+ *
+ * @param ResponseInterface $response The Guzzle response.
+ *
+ * @return string
+ */
+ public function getHeadersAsString(ResponseInterface $response)
+ {
+ $headers = $response->getHeaders();
+ $rawHeaders = [];
+ foreach ($headers as $name => $values) {
+ $rawHeaders[] = $name . ": " . implode(", ", $values);
+ }
+
+ return implode("\r\n", $rawHeaders);
+ }
+}
diff --git a/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookHttpClientInterface.php b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookHttpClientInterface.php
new file mode 100644
index 0000000..0029bc0
--- /dev/null
+++ b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookHttpClientInterface.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Copyright 2014 Facebook, Inc.
+ *
+ * You are hereby granted a non-exclusive, worldwide, royalty-free license to
+ * use, copy, modify, and distribute this software in source code or binary
+ * form for use in connection with the web services and APIs provided by
+ * Facebook.
+ *
+ * As with any software that integrates with the Facebook platform, your use
+ * of this software is subject to the Facebook Developer Principles and
+ * Policies [http://developers.facebook.com/policy/]. This copyright notice
+ * shall be included in all copies or substantial portions of the software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+namespace Facebook\HttpClients;
+
+/**
+ * Interface FacebookHttpClientInterface
+ *
+ * @package Facebook
+ */
+interface FacebookHttpClientInterface
+{
+ /**
+ * Sends a request to the server and returns the raw response.
+ *
+ * @param string $url The endpoint to send the request to.
+ * @param string $method The request method.
+ * @param string $body The body of the request.
+ * @param array $headers The request headers.
+ * @param int $timeOut The timeout in seconds for the request.
+ *
+ * @return \Facebook\Http\GraphRawResponse Raw response from the server.
+ *
+ * @throws \Facebook\Exceptions\FacebookSDKException
+ */
+ public function send($url, $method, $body, array $headers, $timeOut);
+}
diff --git a/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookStream.php b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookStream.php
new file mode 100644
index 0000000..95aa22e
--- /dev/null
+++ b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookStream.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Copyright 2014 Facebook, Inc.
+ *
+ * You are hereby granted a non-exclusive, worldwide, royalty-free license to
+ * use, copy, modify, and distribute this software in source code or binary
+ * form for use in connection with the web services and APIs provided by
+ * Facebook.
+ *
+ * As with any software that integrates with the Facebook platform, your use
+ * of this software is subject to the Facebook Developer Principles and
+ * Policies [http://developers.facebook.com/policy/]. This copyright notice
+ * shall be included in all copies or substantial portions of the software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+namespace Facebook\HttpClients;
+
+/**
+ * Class FacebookStream
+ *
+ * Abstraction for the procedural stream elements so that the functions can be
+ * mocked and the implementation can be tested.
+ *
+ * @package Facebook
+ */
+class FacebookStream
+{
+ /**
+ * @var resource Context stream resource instance
+ */
+ protected $stream;
+
+ /**
+ * @var array Response headers from the stream wrapper
+ */
+ protected $responseHeaders;
+
+ /**
+ * Make a new context stream reference instance
+ *
+ * @param array $options
+ */
+ public function streamContextCreate(array $options)
+ {
+ $this->stream = stream_context_create($options);
+ }
+
+ /**
+ * The response headers from the stream wrapper
+ *
+ * @return array|null
+ */
+ public function getResponseHeaders()
+ {
+ return $this->responseHeaders;
+ }
+
+ /**
+ * Send a stream wrapped request
+ *
+ * @param string $url
+ *
+ * @return mixed
+ */
+ public function fileGetContents($url)
+ {
+ $rawResponse = file_get_contents($url, false, $this->stream);
+ $this->responseHeaders = $http_response_header;
+
+ return $rawResponse;
+ }
+}
diff --git a/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookStreamHttpClient.php b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookStreamHttpClient.php
new file mode 100644
index 0000000..b157514
--- /dev/null
+++ b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookStreamHttpClient.php
@@ -0,0 +1,94 @@
+<?php
+/**
+ * Copyright 2014 Facebook, Inc.
+ *
+ * You are hereby granted a non-exclusive, worldwide, royalty-free license to
+ * use, copy, modify, and distribute this software in source code or binary
+ * form for use in connection with the web services and APIs provided by
+ * Facebook.
+ *
+ * As with any software that integrates with the Facebook platform, your use
+ * of this software is subject to the Facebook Developer Principles and
+ * Policies [http://developers.facebook.com/policy/]. This copyright notice
+ * shall be included in all copies or substantial portions of the software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+namespace Facebook\HttpClients;
+
+use Facebook\Http\GraphRawResponse;
+use Facebook\Exceptions\FacebookSDKException;
+
+class FacebookStreamHttpClient implements FacebookHttpClientInterface
+{
+ /**
+ * @var FacebookStream Procedural stream wrapper as object.
+ */
+ protected $facebookStream;
+
+ /**
+ * @param FacebookStream|null Procedural stream wrapper as object.
+ */
+ public function __construct(FacebookStream $facebookStream = null)
+ {
+ $this->facebookStream = $facebookStream ?: new FacebookStream();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function send($url, $method, $body, array $headers, $timeOut)
+ {
+ $options = [
+ 'http' => [
+ 'method' => $method,
+ 'header' => $this->compileHeader($headers),
+ 'content' => $body,
+ 'timeout' => $timeOut,
+ 'ignore_errors' => true
+ ],
+ 'ssl' => [
+ 'verify_peer' => true,
+ 'verify_peer_name' => true,
+ 'allow_self_signed' => true, // All root certificates are self-signed
+ 'cafile' => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem',
+ ],
+ ];
+
+ $this->facebookStream->streamContextCreate($options);
+ $rawBody = $this->facebookStream->fileGetContents($url);
+ $rawHeaders = $this->facebookStream->getResponseHeaders();
+
+ if ($rawBody === false || !$rawHeaders) {
+ throw new FacebookSDKException('Stream returned an empty response', 660);
+ }
+
+ $rawHeaders = implode("\r\n", $rawHeaders);
+
+ return new GraphRawResponse($rawHeaders, $rawBody);
+ }
+
+ /**
+ * Formats the headers for use in the stream wrapper.
+ *
+ * @param array $headers The request headers.
+ *
+ * @return string
+ */
+ public function compileHeader(array $headers)
+ {
+ $header = [];
+ foreach ($headers as $k => $v) {
+ $header[] = $k . ': ' . $v;
+ }
+
+ return implode("\r\n", $header);
+ }
+}
diff --git a/lib/facebook-graph-sdk/src/Facebook/HttpClients/certs/DigiCertHighAssuranceEVRootCA.pem b/lib/facebook-graph-sdk/src/Facebook/HttpClients/certs/DigiCertHighAssuranceEVRootCA.pem
new file mode 100644
index 0000000..9e6810a
--- /dev/null
+++ b/lib/facebook-graph-sdk/src/Facebook/HttpClients/certs/DigiCertHighAssuranceEVRootCA.pem
@@ -0,0 +1,23 @@
+-----BEGIN CERTIFICATE-----
+MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs
+MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
+d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
+ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL
+MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3
+LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug
+RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm
++9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW
+PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM
+xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB
+Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3
+hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg
+EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF
+MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA
+FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec
+nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z
+eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF
+hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2
+Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
+vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep
++OkuE6N36B9K
+-----END CERTIFICATE-----