How do I use proxies with httplib?
Chad McDaniel
chadm at sgi.com
Thu Apr 22 13:34:05 EDT 1999
Proxy configuration with urllib in Python 1.5.1 is broken. If my memory
serves correctly it gives just the error you describe. Upgrade to the
newly-hatched 1.5.2 and everything should be peachy.
You can download it from:
http://www.python.org/1.5/
On a completely different note: can anyone out there explain what
1.5.1p1 is?
befletch at my-dejanews.com writes:
> In article <099101be8c3f$cb6206e0$f29b12c2 at pythonware.com>,
> "Fredrik Lundh" <fredrik at pythonware.com> wrote:
> > <befletch at my-dejanews.com> wrote:
> > > I want to use httplib through a proxy server and I can't seem to get
> > > it to work.
> [...]
> > you might be able to use urllib instead:
> [...]
>
> When I first looked at this I thought it wouldn't do the trick either,
> since I wanted to use the HTTP POST protocol. On further inspection
> I see that urllib has that covered. So I tried it out, only to run up
> against a problem that I want to blame on urllib; it claims to not
> recognize the http url type:
>
> Python 1.5.1 (#0, Nov 18 1998, 12:17:58) [MSC 32 bit (Intel)] on win32
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import urllib
> >>> connection=urllib.urlopen('http://www.yahoo.com')
>
> Traceback (innermost last): File "<stdin>", line 1, in ? File "C:\PROGRAM
> FILES\HOMERUN\lib\python1.5\urllib.py", line 59, in urlopen return
> _urlopener.open(url) File "C:\PROGRAM
> FILES\HOMERUN\lib\python1.5\urllib.py", line 155, in open return
> self.open_unknown(fullurl) File "C:\PROGRAM
> FILES\HOMERUN\lib\python1.5\urllib.py", line 169, in open_unk nown raise
> IOError, ('url error', 'unknown url type', type) IOError: ('url error',
> 'unknown url type', 'http')
>
> >>>
>
> As a test, I hacked urllib by forcing it to think all url's are http
> url's, like so:
>
> # name = 'open_' + type
> name = 'open_http'
>
> This gets past the url type only to fail on the urllib line:
>
> if not host: raise IOError, ('http error', 'no host given')
>
> Hacking in a host doesn't help much either. Is there something wrong
> with my proxy 'set' command? (This is under W95)
>
> SET http_proxy="100.287.14.130:80"
>
> Thanks again,
> - Bruce
>
> (emailed & posted)
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
-chad
More information about the Python-list
mailing list