[Python-checkins] CVS: python/dist/src/Lib httplib.py,1.38,1.39

Greg Stein gstein@users.sourceforge.net
Sat, 18 Aug 2001 02:20:25 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv21294

Modified Files:
	httplib.py 
Log Message:
Resolve patch #449367.

For the HTTPS class (when available), ensure that the x509 certificate data
gets passed through to the HTTPSConnection class. Create a new
HTTPS.__init__ to do this, and refactor the HTTP.__init__ into a new _setup
method for both init's to call.

Note: this is solved differently from the patch, which advocated a new
**x509 parameter on the base HTTPConnection class. But that would open
HTTPConnection to arbitrary (ignored) parameters, so was not as desirable.



Index: httplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** httplib.py	2001/07/31 08:40:21	1.38
--- httplib.py	2001/08/18 09:20:23	1.39
***************
*** 664,668 ****
      _connection_class = HTTPConnection
  
!     def __init__(self, host='', port=None, **x509):
          "Provide a default host, since the superclass requires one."
  
--- 664,668 ----
      _connection_class = HTTPConnection
  
!     def __init__(self, host='', port=None):
          "Provide a default host, since the superclass requires one."
  
***************
*** 674,689 ****
          # an error when we attempt to connect. Presumably, the client code
          # will call connect before then, with a proper host.
!         self._conn = self._connection_class(host, port)
          # set up delegation to flesh out interface
!         self.send = self._conn.send
!         self.putrequest = self._conn.putrequest
!         self.endheaders = self._conn.endheaders
!         self._conn._http_vsn = self._http_vsn
!         self._conn._http_vsn_str = self._http_vsn_str
  
!         # we never actually use these for anything, but we keep them here for
!         # compatibility with post-1.5.2 CVS.
!         self.key_file = x509.get('key_file')
!         self.cert_file = x509.get('cert_file')
  
          self.file = None
--- 674,690 ----
          # an error when we attempt to connect. Presumably, the client code
          # will call connect before then, with a proper host.
!         self._setup(self._connection_class(host, port))
! 
!     def _setup(self, conn):
!         self._conn = conn
! 
          # set up delegation to flesh out interface
!         self.send = conn.send
!         self.putrequest = conn.putrequest
!         self.endheaders = conn.endheaders
!         self.set_debuglevel = conn.set_debuglevel
  
!         conn._http_vsn = self._http_vsn
!         conn._http_vsn_str = self._http_vsn_str
  
          self.file = None
***************
*** 696,702 ****
          self._conn.connect()
  
-     def set_debuglevel(self, debuglevel):
-         self._conn.set_debuglevel(debuglevel)
- 
      def getfile(self):
          "Provide a getfile, since the superclass' does not use this concept."
--- 697,700 ----
***************
*** 755,758 ****
--- 753,769 ----
  
          _connection_class = HTTPSConnection
+ 
+         def __init__(self, host='', port=None, **x509):
+             # 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, **x509))
+ 
+             # we never actually use these for anything, but we keep them
+             # here for compatibility with post-1.5.2 CVS.
+             self.key_file = x509.get('key_file')
+             self.cert_file = x509.get('cert_file')