Logo Search packages:      
Sourcecode: m2crypto version File versions  Download package

def isaac::HTTPSProxyConnection::connect (   self  ) 

Connect (using SSL) to the host and port specified in __init__ 
(through a proxy).

Reimplemented from isaac::HTTPProxyConnection.

Definition at line 221 of file isaac.httpslib.py.

00221                      :
        """Connect (using SSL) to the host and port specified in __init__ 
        (through a proxy)."""
        import socket
        # Set the connection with the proxy
        HTTPProxyConnection.connect(self)
        # Use the stock HTTPConnection putrequest 
        host = "%s:%s" % (self._host, self._port)
        HTTPConnection.putrequest(self, "CONNECT", host)
        # Add proxy-specific stuff
        self._add_auth_proxy_header()
        # And send the request
        HTTPConnection.endheaders(self)
        # Save the response class
        response_class = self.response_class
        # And replace the response class with our own one, which does not
        # close the connection
        self.response_class = HTTPSProxyResponse
        response = HTTPConnection.getresponse(self)
        # Restore the response class
        self.response_class = response_class
        # Close the response object manually
        response.close()
        if response.status != 200:
            # Close the connection manually
            self.close()
            # XXX Find the appropriate error code
            raise socket.error(1001, response.status, response.value)

        # NgPS: I haven't read the code recently, but I think it is
        # reasonable to assume that self.sock is a connected TCP socket at
        # this point.

        # Use the real stuff. ;-)
        if self.ssl_ctx and isinstance(self.ssl_ctx, SSL.Context):
           self.sock =  SSL.Connection(self.ssl_ctx)
           self.sock.connect((self.host, self.port))
        else:
           # Fake the socket
           ssl = socket.ssl(self.sock, self.key_file, self.cert_file)
           self.sock = FakeSocket(self.sock, ssl)
        if self.debuglevel > 0: print 'socket type:', self.sock

    def putrequest(self, method, url):


Generated by  Doxygen 1.6.0   Back to index