summaryrefslogtreecommitdiff
path: root/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php')
-rw-r--r--lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php57
1 files changed, 5 insertions, 52 deletions
diff --git a/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php
index 955ac06..9516cc8 100644
--- a/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php
+++ b/lib/facebook-graph-sdk/src/Facebook/HttpClients/FacebookCurlHttpClient.php
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 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
@@ -54,16 +54,6 @@ class FacebookCurlHttpClient implements FacebookHttpClientInterface
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)
@@ -108,7 +98,7 @@ class FacebookCurlHttpClient implements FacebookHttpClientInterface
CURLOPT_URL => $url,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => $timeOut,
- CURLOPT_RETURNTRANSFER => true, // Follow 301 redirects
+ CURLOPT_RETURNTRANSFER => true, // Return response as string
CURLOPT_HEADER => true, // Enable header processing
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => true,
@@ -164,47 +154,10 @@ class FacebookCurlHttpClient implements FacebookHttpClientInterface
*/
public function extractResponseHeadersAndBody()
{
- $headerSize = $this->getHeaderSize();
-
- $rawHeaders = mb_substr($this->rawResponse, 0, $headerSize);
- $rawBody = mb_substr($this->rawResponse, $headerSize);
+ $parts = explode("\r\n\r\n", $this->rawResponse);
+ $rawBody = array_pop($parts);
+ $rawHeaders = implode("\r\n\r\n", $parts);
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;
- }
}