From: Kristian Glass Date: Fri, 20 Jul 2012 18:26:08 +0000 (+0100) Subject: Include reason rather than content in raised HTTPErrors X-Git-Tag: v0.13.4~9^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c485928a9f964632cd9556607889aeb1379846b8;p=services%2Fpython-requests.git Include reason rather than content in raised HTTPErrors See https://github.com/kennethreitz/requests/pull/733 for details, TL;DR content is too free-form for this to generally be a good idea. --- diff --git a/requests/models.py b/requests/models.py index e182ac3..0f8f423 100644 --- a/requests/models.py +++ b/requests/models.py @@ -821,16 +821,16 @@ class Response(object): raise self.error if (self.status_code >= 300) and (self.status_code < 400) and not allow_redirects: - http_error = HTTPError('%s Redirection: %s' % (self.status_code, self.content)) + http_error = HTTPError('%s Redirection: %s' % (self.status_code, self.reason)) http_error.response = self raise http_error elif (self.status_code >= 400) and (self.status_code < 500): - http_error = HTTPError('%s Client Error: %s' % (self.status_code, self.content)) + http_error = HTTPError('%s Client Error: %s' % (self.status_code, self.reason)) http_error.response = self raise http_error elif (self.status_code >= 500) and (self.status_code < 600): - http_error = HTTPError('%s Server Error: %s' % (self.status_code, self.content)) + http_error = HTTPError('%s Server Error: %s' % (self.status_code, self.reason)) http_error.response = self raise http_error