--- //Uranus/www/intern/temp/proxycore_alt.py Wed Dec 19 15:25:45 2007 +++ //Uranus/www/intern/temp/proxycore.py Fri Jan 18 11:58:23 2008 @@ -2,6 +2,7 @@ # Copyright (C) 2006, 2007 by Intevation GmbH # Authors: # Bernhard Herzog +# Sascha Bahl # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with the software for details. @@ -14,6 +15,8 @@ import urllib2 import BaseHTTPServer import socket +import cookielib + import inteproxy.transcoder from inteproxy.threadpool import ThreadPool @@ -45,6 +48,11 @@ # >=2 Also logs all the data transferred by the proxy # debug_level = 0 + + # keep the session + cj = cookielib.CookieJar() + opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) + def do_SHUTDOWN(self): """Shutdown the server if self.allow_shutdown is True (default False). @@ -117,6 +125,7 @@ data = None request = urllib2.Request(remote_url) + for header, value in self.headers.items(): if header.lower() == "host": # the host header will be set by httplib and it should @@ -153,6 +162,9 @@ # through to the client. # try: + # Keep the session and resend the server cookies. + urllib2.install_opener(self.opener) + response = urllib2.urlopen(request) except urllib2.HTTPError, err: # a HTTPError is a valid http response object, so we can