twisted.web.http and twisted.web.client handle HTTP status inconsistently.
[email protected] Wed, 23 Dec 2009 17:05:13 -0000
| Newsgroups | gmane.comp.python.twisted.bugs |
|---|---|
| Message-ID | <[email protected]> |
New submission from nejucomo <None>:
The twisted.web.http.Request.setResponseCode() method requires an int argument to represent the HTTP status code to send to a client.
On the other hand, the twisted.web.client.HTTPClientFactory.deferred errback fires with a Failure whose .value.status contains a string representing the HTTP status code in the response from a server. (The errback fires when this status is an error status, such as a 404.)
I assumed I could pass the contents of a Failure to a Request (server-side response) but this raised a type error. A simplified example of the code would look like this:
{{{
def errback(reason):
assert the_reason_represents_a_404_error_response(reason)
myRequest.setResponseCode(reason.value.status)
cfac = HTTPClientFactory('http://www.google.com/nonexistent_path_wombat')
cfac.deferred.addCallbacks(normalHandler, errback)
reactor.connectTCP(cfac.host, cfac.port, cfac)
}}}
----------
Type : enhancement
Component: web
Keywords :
Priority : normal
Nosy :
----------
http://twistedmatrix.com/trac/ticket/4185