Requests icon indicating copy to clipboard operation
Requests copied to clipboard

Proxy Configuration Lost When Following Redirects

Open craig552uk opened this issue 10 years ago • 3 comments

When requesting a URL that returns an HTTP redirect an "fsockopen.connect_error" is thrown, in environments where a proxy must be used.

stream_socket_client(): unable to connect to  (Failed to parse address "")

Dumping the $options passed to Request_Transport_fscockopen->request() shows that the proxy configuration is not being passed through to requests following a redirect.

public function request($url, $headers = array(), $data = array(), $options = array()) {
    var_dump($options);
    // snip //

https://github.com/rmccue/Requests/blob/master/library/Requests/Transport/fsockopen.php#L58

e.g.

Requests::get("http://google.com", [], ['proxy'=>"10.20.0.100:9999"]);

First request:

array (size=16)
  // snip //
  'proxy' => 
    object(Requests_Proxy_HTTP)[3]
      public 'proxy' => string '10.20.0.100:9999' (length=16)
      public 'user' => null
      public 'pass' => null
      public 'use_authentication' => null
  // snip //

Second request:

array (size=16)
  // snip //
  'proxy' => 
    object(Requests_Proxy_HTTP)[8]
      public 'proxy' => null
      public 'user' => null
      public 'pass' => null
      public 'use_authentication' => null
  // snip //

Hard-coding the proxy config at the top of this function resolves the issue.

craig552uk avatar Dec 17 '15 10:12 craig552uk

Action plan:

  1. Needs confirmation if this issue still exists by writing a test to reproduce the issue.
  2. If so: let's get it fixed.
  3. If not: let's close the issue.

jrfnl avatar Feb 28 '22 20:02 jrfnl

Close it mate. It's been 7 years...

craig552uk avatar Feb 28 '22 20:02 craig552uk

Well, even 7-year-old bugs are bugs that should be fixed. We just need to ensure it had not been "inadvertently fixed" in the mean time... 😅

schlessera avatar Apr 25 '22 08:04 schlessera