urllib2 problem with ports.

A

Ant

Hi all,

I have just moved to a new machine, and so have installed the latest
version of Python (2.4.3 - previously I believe I was running 2.4.2).
Unfortunately this seems to have broken urllib2...

An app I wrote for testing our web application makes heavy use of
urllib2 against the localhost, and I am getting the following problem
(minimal code sample):

#/usr/bin/python
import urllib2

urllib2.urlopen("http://localhost:8080/")

This gives the output (Stack trace snipped - can post if required):

urllib2.HTTPError: HTTP Error 502: Proxy Error ( The Uniform Resource
Locator (U
RL) does not use a recognized protocol. Either the protocol is not
supported or
the request was not typed correctly. Confirm that a valid protocol is
in use (fo
r example, HTTP for a Web request). )

This I believe is a problem with the addition of a non-default port.
Replace the url with "http://google.com" for example, and all is well.

Any ideas for workarounds? Or do I roll back to 2.4.2?
 
F

Fredrik Lundh

Ant said:
This gives the output (Stack trace snipped - can post if required):

urllib2.HTTPError: HTTP Error 502: Proxy Error ( The Uniform Resource
Locator (URL) does not use a recognized protocol. Either the protocol
This I believe is a problem with the addition of a non-default port.
Replace the url with "http://google.com" for example, and all is well.

Any ideas for workarounds? Or do I roll back to 2.4.2?

that's not a Python error, so that won't help.

check your proxy configuration. most likely, your new machine is set up
to route all requests via a remote proxy.

(on windows, you'll find the proxy configuration under "Internet
Options" - "Connections" - "LAN Settings". before you do anything else,
make sure "Bypass proxy server for local addresses" is checked)

</F>
 
A

Ant

Fredrik said:
check your proxy configuration. most likely, your new machine is set up
to route all requests via a remote proxy.

Here's me looking like a fool :) The parts of the machine (eg Firefox,
GAIM etc) that I'd set up use a direct connection - it looks like the
guy who'd had the machine before me used a proxy with IE...
(on windows, you'll find the proxy configuration under "Internet
Options" - "Connections" - "LAN Settings". before you do anything else,
make sure "Bypass proxy server for local addresses" is checked)

Interestingly the "Bypass proxy server for local addresses" was
checked. Anyway, I've changed it to a direct connection, and all seems
well. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top