Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.6.0

Request #19332 Add proxy type in cURL adapter
Submitted: 2012-03-15 05:29 UTC
From: till Assigned: avb
Status: Closed Package: HTTP_Request2
PHP Version: Irrelevant OS: n/a
Roadmaps: 2.1.0    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 44 + 47 = ?

 
 [2012-03-15 05:29 UTC] till (Till Klampaeckel)
Description: ------------ cURL supports HTTP and socks5 proxies. This patch adds this feature to the adapter: https://gist.github.com/2040668 A new configuration value: proxy_type Supported values: 'http', 'socks5'. Throws exceptions in case un-supported value is passed or the version of cURL doesn't support it. Version number was taken from the PHP manual: http://docs.php.net/manual/en/function.curl-setopt.php (see CURLOPT PROXYTYPE) Let me know what you think. Till

Comments

 [2012-03-15 12:31 UTC] avb (Alexey Borzov)
-Status: Open +Status: Feedback
I don't want to add features that are supported by one adapter only. Can you estimate what will it take to add SOCKS support to Socket adapter?
 [2012-03-15 15:44 UTC] till (Till Klampaeckel)
I briefly looked at the socket adapeter but didn't dive into it. I know that stream_context_create() supports a proxy directive: http://www.php.net/manual/en/context.http.php I'm not sure what kind of proxy this is though. It seems like it's a simple tcp transport, so it could be socks5 too but I haven't tried it. I'll try to remember when I get to work to write a test script. Till
 [2012-03-15 19:16 UTC] avb (Alexey Borzov)
Too briefly, I should say. Socket adapter does not use 'http' transport, it is a pure PHP implementation of HTTP protocol.
 [2012-03-16 15:27 UTC] doconnor (Daniel O'Connor)
Out of curiosity, why are you against specialisation in certain adapters? Or would you be more comfortable with a HTTP_Request2_CurlProxyAdapter that is obviously specialised?
 [2012-03-16 19:21 UTC] avb (Alexey Borzov)
Because. I won't.
 [2012-03-19 23:27 UTC] till (Till Klampaeckel)
I can't figure out if the socket adapter (through stream_context_create()) even has the potential to support socks5 proxies. Not sure how you would build that in userland if it didn't. I'd second the CurlProxyAdapter thing as well – we could extend the curl adapter for it to work and not add more maintenance.
 [2012-03-20 01:44 UTC] avb (Alexey Borzov)
Your suggestion is extremely valuable to me. However, the feedback I specifically asked for would be even more valuable.
 [2012-03-20 13:33 UTC] avb (Alexey Borzov)
-Status: Feedback +Status: Analyzed -Assigned To: +Assigned To: avb
Looks like SOCKS5 protocol is pretty simple [1] and there are a few PHP implementations available [2], [3] Connection can be done in a way similar to HTTP_Request2_Adapter_Socket::establishTunnel(), probably using a separate HTTP_Request2_SOCKS5 class, Adapter_Socket is pretty bloated as it is. [1] http://www.faqs.org/rfcs/rfc1928.html [2] http://www.phpkode.com/source/s/socks5/socks5/class.socks5.php [3] http://forum.antichat.ru/printthread.php?t=57030
 [2012-03-20 23:31 UTC] avb (Alexey Borzov)
Curl version check in https://gist.github.com/2040668 is redundant: > PHP 5.0.0 requires a libcurl version 7.10.5 or greater. http://ru.php.net/manual/en/curl.requirements.php
 [2012-03-22 17:23 UTC] till (Till Klampaeckel)
Gist updated (removed cURL-version-check): https://gist.github.com/2040668
 [2012-04-03 23:36 UTC] avb (Alexey Borzov)
-Status: Analyzed +Status: Feedback
I've committed 'socks5' proxy support for both Curl and Socket adapters. Please test! Need to do some refactoring though, Adapter_Socket::connect() is 150 lines long and I have trouble understanding it myself... Also SOCKS5 class uses the same wrappers as Adapter_Socket, these should probably be extracted into a separate old-Net_Socket-like class.
 [2012-04-07 13:16 UTC] avb (Alexey Borzov)
-Status: Feedback +Status: Closed
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. -- Did some refactoring, all socket-wrapping code is now in separate class.