WordPress / WordPress/Requests
Proxy Configuration Lost When Following Redirects
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 500
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 5
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in library/Requests/Transport/fsockopen.php around line 58 and inspect Request_Transport_fscockopen->request() handling during redirects. Reproduce the request through an HTTP proxy and verify that the proxy configuration remains available for the redirected request; done means the redirect no longer loses the proxy or fails to parse an empty address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100