Twisted - how to get text for HTTP error responses

koranthala koranthala at
Sun Aug 9 17:35:55 CEST 2009

   I am writing a HTTP client in Twisted. The client contacts the
server, and any errors in the sent messages will be returned back to
the client in 400 message. The reason for failure at the server is
sent as the text in the 400 message. I tried the same using the
browser, and I can see the error text (the text might be like - 'Item
X not found in DB').
   The client is supposed to use this text and calculate the next
messages to be sent to the server. But, I cannot seem to find a
mechanism to get the response text from the errback. I went through, but I couldnt find a way to do it.
I send a data to the server as so
d = defer.waitForDeferred(getPage(url, method='POST', headers=hdr,
yield d
   reply = d.getResult()
except Error, failure:

Now, inside failure method, I was unable to print the text out - say
'Item X not found in DB'.
Is it possible using Twisted? If so, how can it be done?

Thanks in Advance

More information about the Python-list mailing list