Skip to content

Commit

Permalink
Safer error response handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Reitz committed Feb 21, 2011
1 parent 68dea92 commit e788ca7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions requests/core.py
Expand Up @@ -134,10 +134,10 @@ def _get_opener(self):
def _build_response(self, resp):
"""Build internal Response object from given response."""

self.response.status_code = resp.code
self.response.headers = resp.info().dict
self.response.status_code = getattr(resp, 'code', None)
self.response.headers = getattr(resp.info(), 'dict', None)
self.response.url = getattr(resp, 'url', None)
self.response.content = resp.read()
self.response.url = resp.url


def send(self, anyway=False):
Expand Down

1 comment on commit e788ca7

@cocobear
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

防止resp为None

Please sign in to comment.