[Twisted-web] HTTPClientFactory questions

Tommi Virtanen tv at twistedmatrix.com
Thu Feb 10 14:42:53 MST 2005

snacktime wrote:
> I'm trying to figure out the best way to catch all the different
> possible errors when using HTTPClientFactory and am kind of stuck.
> First, what is the best way to catch errors before or during the
> connection, such as connection time outs or dns lookup errors? If a
> response isn't sent to the client, status,version, and message will
> never get set.  I need the status code for all responses, but I need a
> way to catch all errors that don't set the status so I know if status
> is available or not.
> I tried inheriting HTTPClientFactory and providing my own
> clientConnectionFailed() method, and that's when I ran into another
> issue.  I happened to try connecting to a host that gave me an ssl
> handshake failure, and an exception was caught in twisted.internet.tcp
> and printed.  However it didn't register an errback but went ahead
> with the callback (complete code is below).

The error is server not supporting SSL3.0.
HTTPClientFactory.connectionLost is called.
HTTPPageGetter.connectionLost is called.
   http.HTTPClient.connectionLost is called.
     http.HTTPClient.handleResponseEnd is called.
     HTTPPageGetter.handleResponse is called with "".
       self.failed is 0
       self.length is None
       HTTPClientFactory.page is called with ""
       HTTPPageGetter.transport.loseConnection is called.
     HTTPClientFactory.noPage is called.

Hmmph, seems like that case should show up as an error and not a
successful 0-length page.

Please see these for more:


More information about the Twisted-web mailing list