Skip to content

Proxy Configuration Lost When Following Redirects #199

@craig552uk

Description

@craig552uk

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions