Allowing hooks to return responses that indicate errors
authorMichael Komitee <komitee@deshaw.com>
Fri, 1 Jun 2012 19:53:23 +0000 (15:53 -0400)
committerMichael Komitee <komitee@deshaw.com>
Fri, 1 Jun 2012 20:05:22 +0000 (16:05 -0400)
commit662c3edacc76d6a0e7b55b569c9fea38f8b0bc78
tree9659c7b55573b65d008cd95f9b3f97c16589f339
parent77a57c0e7e669173241a56670ba4d096a303c75e
Allowing hooks to return responses that indicate errors

Since response objects for failures (4xx/5xx responses) evaluate to False
in a boolean context, any hook which returns such a failure response will
evaluate to False.

The way hooks were setup, any failure response resulting from a hook would
be ignored, and the initial response before it got processed by the hook
would be substituted in its place. This commit changes that logic to test
for None so that hooks that return failures can do so.
requests/hooks.py