Parcourir la source

* fix to ssl_socket makefile method and utils _should_use_proxy

git-svn-id: http://proj.badc.rl.ac.uk/svn/ndg-security/trunk/ndg_httpsclient@8099 051b1e3e-aa0c-0410-b6c2-bfbade6052be
pjkersha il y a 12 ans
Parent
commit
ecd9b0ea1f
2 fichiers modifiés avec 14 ajouts et 12 suppressions
  1. 13 11
      ndg/httpsclient/ssl_socket.py
  2. 1 1
      ndg/httpsclient/utils.py

+ 13 - 11
ndg/httpsclient/ssl_socket.py

@@ -216,7 +216,7 @@ class SSLSocket(object):
         """Return the SSL state of this connection."""
         return self.__ssl_conn.state_string()
 
-    def _DEPRECATE_makefile(self, *args):
+    def makefile(self, *args):
         """Specific to Python socket API and required by httplib: convert
         response into a file-like object.  This implementation reads using recv
         and copies the output into a StringIO buffer to simulate a file object
@@ -230,6 +230,8 @@ class SSLSocket(object):
         @return: file object for data returned from socket
         @rtype: cStringIO.StringO
         """
+        self._makefile_refs += 1
+        
         # Optimisation
         _buf_size = self.buf_size
 
@@ -260,16 +262,16 @@ class SSLSocket(object):
 
         return stream
 
-    def makefile(self, mode='r', bufsize=-1):
-
-        """Make and return a file-like object that
-        works with the SSL connection.  Just use the code
-        from the socket module."""
-
-        self._makefile_refs += 1
-        # close=True so as to decrement the reference count when done with
-        # the file-like object.
-        return socket._fileobject(self.socket, mode, bufsize, close=True)
+#    def makefile(self, mode='r', bufsize=-1):
+#
+#        """Make and return a file-like object that
+#        works with the SSL connection.  Just use the code
+#        from the socket module."""
+#
+#        self._makefile_refs += 1
+#        # close=True so as to decrement the reference count when done with
+#        # the file-like object.
+#        return socket._fileobject(self.socket, mode, bufsize, close=True)
     
     def getsockname(self):
         """

+ 1 - 1
ndg/httpsclient/utils.py

@@ -186,7 +186,7 @@ def open_url(url, config, data=None):
     return (return_code, return_message, response)
 
 
-def _should_use_proxy(url, no_proxy):
+def _should_use_proxy(url, no_proxy=None):
     """Determines whether a proxy should be used to open a connection to the 
     specified URL, based on the value of the no_proxy environment variable.
     @param url: URL