summaryrefslogtreecommitdiff
path: root/M2Crypto
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2012-03-15 03:23:43 +0200
committerMatěj Cepl <mcepl@cepl.eu>2015-10-13 15:23:20 +0200
commit2637899d810329bbc5e37bdbb23680af39370fc5 (patch)
treee17a50651e039a7bbc820625ff1e8d23889c7730 /M2Crypto
parent65a57cf20245861558c071aeb0381bf17b7bd893 (diff)
downloadm2crypto-2637899d810329bbc5e37bdbb23680af39370fc5.tar.gz
Fix https connections over a proxy with Python >= 2.6
Make m2urllib2 allow use of the relative paths in requests, which make M2Crypto more proxy-friendly and working with some caches which don't allow mixing two different URLs for the same resource. See https://bugzilla.redhat.com/show_bug.cgi?id=803554 and https://bugzilla.redhat.com/show_bug.cgi?id=491674 for more information.
Diffstat (limited to 'M2Crypto')
-rw-r--r--M2Crypto/httpslib.py4
-rw-r--r--M2Crypto/m2urllib2.py4
2 files changed, 5 insertions, 3 deletions
diff --git a/M2Crypto/httpslib.py b/M2Crypto/httpslib.py
index d2f8c69..6967a3a 100644
--- a/M2Crypto/httpslib.py
+++ b/M2Crypto/httpslib.py
@@ -181,14 +181,14 @@ class ProxyHTTPSConnection(HTTPSConnection):
else:
HTTPSConnection.putheader(self, header, value)
- def endheaders(self):
+ def endheaders(self, *args, **kwargs):
# We've recieved all of hte headers. Use the supplied username
# and password for authorization, possibly overriding the authstring
# supplied in the headers.
if not self._proxy_auth:
self._proxy_auth = self._encode_auth()
- HTTPSConnection.endheaders(self)
+ HTTPSConnection.endheaders(self, *args, **kwargs)
def connect(self):
HTTPConnection.connect(self)
diff --git a/M2Crypto/m2urllib2.py b/M2Crypto/m2urllib2.py
index e500410..281e423 100644
--- a/M2Crypto/m2urllib2.py
+++ b/M2Crypto/m2urllib2.py
@@ -64,8 +64,10 @@ class HTTPSHandler(AbstractHTTPHandler):
target_host = urlparse.urlparse(full_url)[1]
if (target_host != host):
+ request_uri = urlparse.urldefrag(full_url)[0]
h = httpslib.ProxyHTTPSConnection(host = host, ssl_context = self.ctx)
else:
+ request_uri = req.get_selector()
h = httpslib.HTTPSConnection(host = host, ssl_context = self.ctx)
# End our change
h.set_debuglevel(self._debuglevel)
@@ -80,7 +82,7 @@ class HTTPSHandler(AbstractHTTPHandler):
# request.
headers["Connection"] = "close"
try:
- h.request(req.get_method(), req.get_selector(), req.data, headers)
+ h.request(req.get_method(), request_uri, req.data, headers)
r = h.getresponse()
except socket.error, err: # XXX what error?
raise URLError(err)