ipapython.nsslib: Remove NSSHTTPS

This workaround is unused in Python 2.7+.

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Viktorin 2015-10-20 18:50:13 +02:00 committed by Tomas Babej
parent 4ddd1821b6
commit 6811b4be6a
2 changed files with 1 additions and 69 deletions

View File

@ -60,7 +60,7 @@ from ipapython.cookie import Cookie
from ipapython.dnsutil import DNSName from ipapython.dnsutil import DNSName
from ipalib.text import _ from ipalib.text import _
import ipapython.nsslib import ipapython.nsslib
from ipapython.nsslib import NSSHTTPS, NSSConnection from ipapython.nsslib import NSSConnection
from ipalib.krb_utils import KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN, KRB5KRB_AP_ERR_TKT_EXPIRED, \ from ipalib.krb_utils import KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN, KRB5KRB_AP_ERR_TKT_EXPIRED, \
KRB5_FCC_PERM, KRB5_FCC_NOFILE, KRB5_CC_FORMAT, \ KRB5_FCC_PERM, KRB5_FCC_NOFILE, KRB5_CC_FORMAT, \
KRB5_REALM_CANT_RESOLVE, KRB5_CC_NOTFOUND, get_principal KRB5_REALM_CANT_RESOLVE, KRB5_CC_NOTFOUND, get_principal

View File

@ -295,71 +295,3 @@ class NSSConnection(httplib.HTTPConnection, NSSAddressFamilyFallback):
except NSPRError as e: except NSPRError as e:
self.close() self.close()
raise e raise e
class NSSHTTPS(httplib.HTTP):
# We would like to use HTTP 1.1 not the older HTTP 1.0 but xmlrpc.client
# and httplib do not play well together. httplib when the protocol
# is 1.1 will add a host header in the request. But xmlrpc.client
# always adds a host header irregardless of the HTTP protocol
# version. That means the request ends up with 2 host headers,
# but Apache freaks out if it sees 2 host headers, a known Apache
# issue. httplib has a mechanism to skip adding the host header
# (i.e. skip_host in HTTPConnection.putrequest()) but xmlrpc.client
# doesn't use it. Oh well, back to 1.0 :-(
#
#_http_vsn = 11
#_http_vsn_str = 'HTTP/1.1'
_connection_class = NSSConnection
def __init__(self, host='', port=None, strict=None, dbdir=None, no_init=False):
# provide a default host, pass the X509 cert info
# urf. compensate for bad input.
if port == 0:
port = None
self._setup(self._connection_class(host, port, strict, dbdir=dbdir, no_init=no_init))
def getreply(self):
"""
Override so we can close duplicated file connection on non-200
responses. This was causing nss_shutdown() to fail with a busy
error.
"""
(status, reason, msg) = httplib.HTTP.getreply(self)
if status != 200:
self.file.close()
return (status, reason, msg)
#------------------------------------------------------------------------------
if __name__ == "__main__":
standard_logging_setup('nsslib.log', debug=True, filemode='a')
root_logger.info("Start")
if False:
conn = NSSConnection("www.verisign.com", 443, dbdir=paths.NSS_DB_DIR)
conn.set_debuglevel(1)
conn.connect()
conn.request("GET", "/")
response = conn.getresponse()
print(response.status)
#print response.msg
print(response.getheaders())
data = response.read()
#print data
conn.close()
if True:
h = NSSHTTPS("www.verisign.com", 443, dbdir=paths.NSS_DB_DIR)
h.connect()
h.putrequest('GET', '/')
h.endheaders()
http_status, http_reason, headers = h.getreply()
print("status = %s %s" % (http_status, http_reason))
print("headers:\n%s" % headers)
f = h.getfile()
data = f.read() # Get the raw HTML
f.close()
#print data