mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-23 10:03:47 +03:00
Minor cleanup (we officially support Python >= 2.6)
This commit is contained in:
parent
db91137eda
commit
81848c723d
|
@ -7,14 +7,12 @@ See the file 'doc/COPYING' for copying permission
|
||||||
|
|
||||||
import httplib
|
import httplib
|
||||||
import socket
|
import socket
|
||||||
|
import ssl
|
||||||
import urllib
|
import urllib
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
from lib.core.exception import SqlmapUnsupportedFeatureException
|
from lib.core.exception import SqlmapUnsupportedFeatureException
|
||||||
from lib.core.settings import PYVERSION
|
|
||||||
|
|
||||||
if PYVERSION >= "2.6":
|
|
||||||
import ssl
|
|
||||||
|
|
||||||
class ProxyHTTPConnection(httplib.HTTPConnection):
|
class ProxyHTTPConnection(httplib.HTTPConnection):
|
||||||
_ports = {"http": 80, "https": 443}
|
_ports = {"http": 80, "https": 443}
|
||||||
|
@ -82,12 +80,8 @@ class ProxyHTTPSConnection(ProxyHTTPConnection):
|
||||||
ProxyHTTPConnection.connect(self)
|
ProxyHTTPConnection.connect(self)
|
||||||
|
|
||||||
# Make the sock ssl-aware
|
# Make the sock ssl-aware
|
||||||
if PYVERSION >= "2.6":
|
|
||||||
sslobj = ssl.wrap_socket(self.sock, self.key_file, self.cert_file)
|
sslobj = ssl.wrap_socket(self.sock, self.key_file, self.cert_file)
|
||||||
self.sock = sslobj
|
self.sock = sslobj
|
||||||
else:
|
|
||||||
sslobj = socket.ssl(self.sock, self.key_file, self.cert_file)
|
|
||||||
self.sock = httplib.FakeSocket(self.sock, sslobj)
|
|
||||||
|
|
||||||
class ProxyHTTPHandler(urllib2.HTTPHandler):
|
class ProxyHTTPHandler(urllib2.HTTPHandler):
|
||||||
def __init__(self, proxy=None, debuglevel=0):
|
def __init__(self, proxy=None, debuglevel=0):
|
||||||
|
@ -101,7 +95,6 @@ class ProxyHTTPHandler(urllib2.HTTPHandler):
|
||||||
|
|
||||||
return urllib2.HTTPHandler.do_open(self, ProxyHTTPConnection, req)
|
return urllib2.HTTPHandler.do_open(self, ProxyHTTPConnection, req)
|
||||||
|
|
||||||
if PYVERSION >= "2.6":
|
|
||||||
class ProxyHTTPSHandler(urllib2.HTTPSHandler):
|
class ProxyHTTPSHandler(urllib2.HTTPSHandler):
|
||||||
def __init__(self, proxy=None, debuglevel=0):
|
def __init__(self, proxy=None, debuglevel=0):
|
||||||
self.proxy = proxy
|
self.proxy = proxy
|
||||||
|
@ -113,8 +106,3 @@ if PYVERSION >= "2.6":
|
||||||
req.set_proxy(self.proxy, "https")
|
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)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user