classification
Title: urllib proxy interface is too limited
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Dominique.Leuenberger, ronaldoussoren
Priority: normal Keywords:

Created on 2010-03-07 11:22 by ronaldoussoren, last changed 2010-03-09 10:58 by Dominique.Leuenberger.

Messages (2)
msg100573 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-03-07 11:22
The proxy support code in urllib is imho too specific and cannot easily support dynamic proxy configuration using a proxy.pac file.

That is, the code assumes that there is at most one proxy per protocol, while this is not quite true in practice.  A proxy.pac can refer different URLs to different proxies (or exclude some from proxying).

This could be solved by adding a new proxy hook to urllib, something like:

def getproxies_for_url(url) -> [info, ...]

That is, the argument is the string for an URL, the result is a list of proxies that can be used to fetch the URL.

This hook would allow us to provide a hook on OSX that enables python scripts to use the system proxy settings, even when those are complex (such as by using proxy autoconfiguration).
msg100714 - (view) Author: Dominique Leuenberger (Dominique.Leuenberger) Date: 2010-03-09 10:58
I like the idea of having the proxy handler expanded. In fact I suggest to base the idea on libproxy ( http://code.google.com/p/libproxy ) which is available on Linux / openSolaris / Windows and Mac (currently).

Libproxy queries the correct settings to be used from KDE and gnome, depending on the currently running session. A fallback is of course env.

the API of libproxy is very simple and python bindings are available.
History
Date User Action Args
2010-03-09 10:58:28Dominique.Leuenbergersetnosy: + Dominique.Leuenberger
messages: + msg100714
2010-03-07 11:22:53ronaldoussorencreate