Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with stripping CURLs proxy response output #122

Closed
KingPrawnBalls opened this issue Feb 28, 2014 · 4 comments
Closed

Problems with stripping CURLs proxy response output #122

KingPrawnBalls opened this issue Feb 28, 2014 · 4 comments

Comments

@KingPrawnBalls
Copy link

The proxy response stripping code in Request->send() function has two issues preventing it from working with our proxy:

  1. it only checks for HTTP/1.0 not 1.x before the "Connection established" string
  2. it doesn't strip further HTTP headers returned by the proxy after the status line (see http://curl.haxx.se/mail/lib-2005-10/0023.html for examples)

I suggest this code change, which has fixed both issues for us:

/** Remove the "HTTP/1.x 200 Connection established" string and any other headers added by proxy
 *  RegEx notes:
 *     /s   - this option after the match string changes . char to also match newlines
 *     .*?  - the ? makes the * lazy rather than it's normal greedy behaviour, so it doesn't consume the \r\n\r\n following it
 */
if ($this->hasProxy() && preg_match("/HTTP\/1\.[01] 200 Connection established.*?\r\n\r\n/s", $result)) {
  $result = preg_replace("/HTTP\/1\.[01] 200 Connection established.*?\r\n\r\n/s", '', $result);
}
@nategood
Copy link
Owner

Thanks Paul. I'll review shortly.
On Feb 28, 2014 8:03 AM, "Paul Harding" notifications@github.com wrote:

The proxy response stripping code in Request->send() function has two
issues preventing it from working with our proxy:

  1. it only checks for HTTP/1.0 not 1.x before the "Connection established"
    string
  2. it doesn't strip further HTTP headers returned by the proxy after the
    status line (see http://curl.haxx.se/mail/lib-2005-10/0023.html for
    examples)

I suggest this code change, which has fixed both issues for us:

/** Remove the "HTTP/1.x 200 Connection established" string and any other headers added by proxy

  • RegEx notes:
  • /s   - this option after the match string changes . char to also match newlines
    
  • ._?  - the ? makes the \* lazy rather than it's normal greedy behaviour, so it doesn't consume the \r\n\r\n following it
    
    /
    if ($this->hasProxy() && preg_match("/HTTP/1.[01] 200 Connection established._?\r\n\r\n/s", $result)) {
    $result = preg_replace("/HTTP/1.[01] 200 Connection established.
    ?\r\n\r\n/s", '', $result);
    }

Reply to this email directly or view it on GitHubhttps://github.com//issues/122
.

@KingPrawnBalls
Copy link
Author

Hi Nate, did you get any time to look over this?

nategood pushed a commit that referenced this issue May 21, 2014
@nategood
Copy link
Owner

See d485510

@KingPrawnBalls
Copy link
Author

Great! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants