Proxy Configuration Lost When Following Redirects
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.
Action plan:
- Needs confirmation if this issue still exists by writing a test to reproduce the issue.
- If so: let's get it fixed.
- If not: let's close the issue.
Close it mate. It's been 7 years...
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... 😅