From 27d76847fe679ee5d0fbaba484374980a419d83f Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 1 Sep 2010 08:46:21 +0000 Subject: [PATCH] fix for bug reported by Truong Duc Luong --- lib/request/proxy.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/request/proxy.py b/lib/request/proxy.py index f64eec389..3eccf10a0 100644 --- a/lib/request/proxy.py +++ b/lib/request/proxy.py @@ -27,6 +27,7 @@ import socket import urllib import urllib2 +from lib.core.exception import sqlmapUnsupportedFeatureException from lib.core.settings import PYVERSION if PYVERSION >= "2.6": @@ -117,14 +118,20 @@ class ProxyHTTPHandler(urllib2.HTTPHandler): return urllib2.HTTPHandler.do_open(self, ProxyHTTPConnection, req) -class ProxyHTTPSHandler(urllib2.HTTPSHandler): - def __init__(self, proxy=None, debuglevel=0): - self.proxy = proxy +if PYVERSION >= "2.6": + class ProxyHTTPSHandler(urllib2.HTTPSHandler): + def __init__(self, proxy=None, debuglevel=0): + self.proxy = proxy - urllib2.HTTPSHandler.__init__(self, debuglevel) + urllib2.HTTPSHandler.__init__(self, debuglevel) - def do_open(self, http_class, req): - if self.proxy is not None: - req.set_proxy(self.proxy, "https") + def do_open(self, http_class, req): + if self.proxy is not None: + req.set_proxy(self.proxy, "https") - return urllib2.HTTPSHandler.do_open(self, ProxyHTTPSConnection, req) + return urllib2.HTTPSHandler.do_open(self, ProxyHTTPSConnection, req) +else: + class ProxyHTTPSHandler: + def __init__(self, *args, **kwargs): + errMsg = "unsupported feature on versions of Python before 2.6" + raise sqlmapUnsupportedFeatureException, errMsg