diff --git a/src/Httpful/Request.php b/src/Httpful/Request.php index f287077..18b1f4c 100644 --- a/src/Httpful/Request.php +++ b/src/Httpful/Request.php @@ -207,10 +207,12 @@ public function send() $info = curl_getinfo($this->_ch); - //Remove the "HTTP/1.0 200 Connection established" string - if ($this->hasProxy() && false !== stripos($result, "HTTP/1.0 200 Connection established\r\n\r\n")) { - $result = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $result); + // Remove the "HTTP/1.x 200 Connection established" string and any other headers added by proxy + $proxy_regex = "/HTTP\/1\.[01] 200 Connection established.*?\r\n\r\n/s"; + if ($this->hasProxy() && preg_match($proxy_regex, $result)) { + $result = preg_replace($proxy_regex, '', $result); } + $response = explode("\r\n\r\n", $result, 2 + $info['redirect_count']); $body = array_pop($response);