-
Notifications
You must be signed in to change notification settings - Fork 498
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
SOCKS5 support #109
SOCKS5 support #109
Conversation
* | ||
* @since 1.6 | ||
* @throws Requests_Exception On incorrect number of arguments (`authbasicbadargs`) | ||
* @param array|null $args Array of user and password. Must have exactly two elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"MUst have exactly 2 elements" is not correct
* @param Requests_Hooks $hooks Hook system | ||
*/ | ||
public function register(Requests_Hooks &$hooks) { | ||
$hooks->register('curl.before_send', array(&$this, 'curl_before_send')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why oass by ref, this should trigger a warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know, I just copy/past the original HTTP proxy library (in Requests).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe merging HTTP, SOCKS4 and SOCKS5 support in one file may be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@staabm Won't cause a warning, but you're correct that it's not needed, just a bad habit of mine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, separate files for different proxies is better. Should be one-class-per-file, and HTTP/SOCKS5 should definitely be separate classes.
@@ -500,8 +500,18 @@ protected static function set_defaults(&$url, &$headers, &$data, &$type, &$optio | |||
$options['auth']->register($options['hooks']); | |||
} | |||
|
|||
if (!empty($options['proxy'])) { | |||
$options['proxy'] = new Requests_Proxy_HTTP($options['proxy']); | |||
if (!empty($options['proxy']['authentication']) AND |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be &&
instead of AND
. The latter has a different precedence that can be confusing to work with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, habit... ;)
Thanks for this! :) Two concerns I have:
If we add a test SOCKS proxy to the tests, that solves both issues for me, but I'm not sure the easiest way to do that. |
I tested the HTTP proxy support days ago, it don't works. Got an error on CONNECT request or something like that. But I can confirm that the cURL SOCKS Support I made quickly works well. |
Hmm, interesting. What were you using to test? @ozh Do you have a test HTTP proxy setup I can use to check this?
I'd like to be able to independently confirm that. :) I'll check out if mitmproxy can do it; we might be able to work this into #75. |
Comment removed by mistake. S***. So, in short, download TorBrowser Bundle, run it and then add this in the Requests options:
You should be able to try. |
This was pretty simple and it works well (for cURL)