From fe918730f09618ab0973088b1b80ce3a00c6128d Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 21 May 2014 05:44:16 -0400 Subject: [PATCH] Better proxy request scrubbing See [Issue 123](https://github.com/nategood/httpful/issues/123) --- src/Httpful/Request.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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);