Skip to content

Commit

Permalink
Better proxy request scrubbing
Browse files Browse the repository at this point in the history
See [Issue 122](#122)
  • Loading branch information
Nathan committed May 21, 2014
1 parent 24a481d commit d485510
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Httpful/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d485510

Please sign in to comment.