[Twisted-web] twisted.web getPage-- retrieving error information

David E. Konerding dekonerding at lbl.gov
Wed Oct 19 14:36:36 MDT 2005


Hi folks,

I am tryign to get useful error information when I use 
twisted.web.getPage.  For example, this code doesn't supply a trailing
slash when making a request for www.google.com.  This causes getPage to 
make an invalid request to the web server
("GET  HTTP/1.1") which causes the server to disconnect immediately 
(that's true for the google web server.  for apache, it produces
an "Invalid Request" message and error code).

It doens't seem like the error object passed to the errback contains any 
useful information which I can bubble up to the user.
For example, I'd like to know what data was received before the server 
closed the connection.  ANy ideas?

from twisted.internet import reactor
from twisted.web.client import getPage

def gotPage(result):
    print "gotPage: result=", result

def gotPageErr(error):
    print "gotPageErr: error=", error
   
def getAPage(url):
    gp = getPage(url)
    gp.addCallback(gotPage)
    gp.addErrback(gotPageErr)

reactor.callWhenRunning(getAPage, "http://google.com")
reactor.run()





More information about the Twisted-web mailing list