From: Gredler, Daniel (Matrix) <Daniel.G<redler@ic...> - 2004-10-29 17:54:27
Using the environment variable "http_proxy" does not seem to work. Below is
a snippet of code that executes without a problem under Python 2.3, but does
*not* execute correctly under Jython 2.1.
os.environ['http_proxy'] = 'http://my.proxy.com:5865';
file = urllib.urlopen('http://www.google.com/';)
html = file.read()
I get the following stack trace under Jython 2.1:
Traceback (innermost last):
File "test.py", line 5, in ?
File "C:\java\jython-2.1\Lib\urllib.py", line 71, in urlopen
File "C:\java\jython-2.1\Lib\urllib.py", line 176, in open
File "C:\java\jython-2.1\Lib\urllib.py", line 287, in open_http
File "C:\java\jython-2.1\Lib\httplib.py", line 504, in endheaders
File "C:\java\jython-2.1\Lib\httplib.py", line 394, in send
According to a past thread in this email list, the above error is caused by
differences between the Python Exception class and the Java Exception class.
If I modify httplib.py to print the exception before doing the
Python-specific checks that break, I get the following message printed out:
java.net.SocketException: Software caused connection abort: socket write
Has anyone else used httplib or urllib in Jython with an HTTP proxy?
Thanks in advance,
From: Diez B. Roggisch [mailto:deets@...]
Sent: Friday, October 29, 2004 9:34 AM
Subject: Re: [Jython-users] Using Jython with an HTTP proxy
> The problem is that we have a firewall and have to use a proxy to get to
> the web. I have tried specifying the java system properties http.proxyHost
> and http.proxyPort, as well as calling PythonInterpreter.initialize() with
> a property keyed on "http_proxy", which is apparently the convention for
> specifying proxies with urllib (see
> http://www.python.org/doc/current/lib/module-urllib.html). I am not sure
> what to try next. As noted in the code, printing out the list of proxies
> always gives me an empty list even when trying to specify the proxy using
> aforementioned methods. Any pointers would be greatly appreciated.
Use an environment-variable http_proxy. Then invoke jython command line,
import module os and print os.environment - if the http_proxy value shows
up there, things should work - at least the urllib.py in jython's lib