Changeset 8096


Ignore:
Timestamp:
17/08/12 12:50:12 (8 years ago)
Author:
pjkersha
Message:
 
Location:
trunk/ndg_httpsclient/ndg/httpsclient
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ndg_httpsclient/ndg/httpsclient/https.py

    r7993 r8096  
    8484        self.sock.close() 
    8585         
    86  
     86         
    8787class HTTPSContextHandler(AbstractHTTPHandler): 
    8888    '''HTTPS handler that allows a SSL context to be set for the SSL 
  • trunk/ndg_httpsclient/ndg/httpsclient/ssl_socket.py

    r7993 r8096  
    4747        self.__ssl_conn = SSL.Connection(ctx, self.socket) 
    4848        self.buf_size = self.__class__.default_buf_size 
     49        self._makefile_refs = 0 
    4950 
    5051    def __del__(self): 
     
    6970        """Shutdown the SSL connection and call the close method of the 
    7071        underlying socket""" 
    71         try: 
     72#        try: 
     73#            self.__ssl_conn.shutdown() 
     74#        except SSL.Error: 
     75#            # Make errors on shutdown non-fatal 
     76#            pass 
     77 
     78        if self._makefile_refs < 1:         
    7279            self.__ssl_conn.shutdown() 
    73         except SSL.Error: 
    74             # Make errors on shutdown non-fatal 
    75             pass 
    76          
    77         self.__ssl_conn.close() 
     80        else: 
     81            self._makefile_refs -= 1 
    7882 
    7983    def set_shutdown(self, mode): 
     
    213217        return self.__ssl_conn.state_string() 
    214218 
    215     def makefile(self, *args): 
     219    def _DEPRECATE_makefile(self, *args): 
    216220        """Specific to Python socket API and required by httplib: convert 
    217221        response into a file-like object.  This implementation reads using recv 
     
    257261        return stream 
    258262 
     263    def makefile(self, mode='r', bufsize=-1): 
     264 
     265        """Make and return a file-like object that 
     266        works with the SSL connection.  Just use the code 
     267        from the socket module.""" 
     268 
     269        self._makefile_refs += 1 
     270        # close=True so as to decrement the reference count when done with 
     271        # the file-like object. 
     272        return socket._fileobject(self.socket, mode, bufsize, close=True) 
     273     
    259274    def getsockname(self): 
    260275        """ 
  • trunk/ndg_httpsclient/ndg/httpsclient/utils.py

    r8053 r8096  
    161161        log.debug("Configuring proxies: %s" % config.proxies) 
    162162 
    163     opener = build_opener(config.ssl_context, *handlers) 
     163    opener = build_opener(*handlers, ssl_context=config.ssl_context) 
    164164 
    165165    # Open the URL and check the response. 
Note: See TracChangeset for help on using the changeset viewer.