Skip to content
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

Support PROXY_TYPE_HTTP_NO_TUNNEL #2

Closed
fmoo opened this issue Jan 12, 2013 · 4 comments
Closed

Support PROXY_TYPE_HTTP_NO_TUNNEL #2

fmoo opened this issue Jan 12, 2013 · 4 comments

Comments

@fmoo
Copy link
Contributor

fmoo commented Jan 12, 2013

httplib2 took a patch to add a new proxy type, HTTP_NO_TUNNEL in https://code.google.com/p/httplib2/issues/detail?id=38. Basically this allows you to specify that you want to use an HTTP proxy, but you do not want to use the CONNECT method for connecting to https://

@fmoo
Copy link
Contributor Author

fmoo commented Jan 12, 2013

I might have the bandwidth to work on this in a week or two, but just filing this to track in the meantime.

mikedougherty pushed a commit that referenced this issue Jan 14, 2013
This change has been ported from httplib2.
The original change is here: https://code.google.com/p/httplib2/source/detail?r=f6701a80444e
Discussion is here: https://code.google.com/p/httplib2/issues/detail?id=38

(for issue #2)
@mikedougherty
Copy link
Owner

So there's a port of the patch from httplib2, but I haven't tested it yet so it's still sitting in a branch. I'm not sure if you had more in mind than this.

Though I have take no issue with supporting this use case, I'm having trouble understanding it. I've always taken this module (socks.py) is to be a replacement for 'socket' (more specifically TCP sockets), i.e. transport layer. Using HTTP(S) with CONNECT enables the use of connect, send, recv, close, getpeername and so on, and any TCP application can use it as a substitute for a 'vanilla' socket. Using HTTP's proxy support over HTTP is purely application-layer and I think should be the responsibility of whatever's using the socket (*see below). Unless there's something I'm unaware of, with HTTP_NO_TUNNEL a socks.socksocket would only be capable of making single HTTP request in the very naive fashion of sck.connect(server); sck.sendall(http_req); response = sck.recv(HUGE_BUFSIZE); sck.close().

* For example, urllib2 and the python3 equivalent offer ProxyHandler and ProxyBasicAuthHandler to perform this task. After some simple googling, it seems like httplib2 does not offer this, which I honestly find surprising. Oh well ;)

@mikedougherty
Copy link
Owner

Closing this in the interest of #4 - let's direct development towards PySocks.

(...also there's been no activity here for months)

@Anorov
Copy link

Anorov commented May 8, 2013

Though this is dead, this is actually something I considered quite a bit while upgrading PySocks.

In short: if one looks at how HTTP proxying works, both in the cases of CONNECT tunnels and regular HTTP proxies, it is much more sensible to implement this at the HTTP client layer, and not a separate proxying library. SOCKS proxies and HTTP proxies are very different in nature.

So, basically exactly what @mikedougherty said.

In PySocks, I decided not to implement regular HTTP proxying, though I did keep the original CONNECT tunnelling method. I added copious amounts of comments and helpful exception messages to indicate that it only supports CONNECT-style proxying, and not traditional HTTP proxying. I would highly advise relying on your HTTP client's proxying features, and to avoid all SocksiPy/PySocks HTTP-related code entirely.

The urllib3 library (which is similar in scope to httplib2, but in combination with the requests library is in my opinion a better and cleaner result) currently has full support for regular HTTP proxying, and CONNECT proxying for https. So it should be just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants