Skip to content
Myr

Merge pull request #542 from newmaniese/develop

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Attempting to address issue #377 by making content on the response model a little smarter

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 7d4d91f, 11cd2b8 · Browse files · 3 files+10 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−4 removed

  • tests:+5 added−0 removed
  • other:+5 added−4 removed

3 files+10 added−4 removed

modified:requests/models.py+3 added-3 removed
621 unmodified lines
622 """623624 def __init__(self):625626 self._content = None626 self._content = False627 self._content_consumed = False628629 #: Integer Code of responded HTTP Status.630 self.status_code = None
104 unmodified lines
735 @property736 def content(self):737 """Content of the response, in bytes."""738739 if self._content is None:739 if self._content is False:740 # Read the contents.741 try:742 if self._content_consumed:743 raise RuntimeError(
6 unmodified lines
750751 except AttributeError:752 self._content = None753754 self._content_consumed = True754 self._content_consumed = True 755 return self._content756757 def _detected_encoding(self):758 try:
59 unmodified lines
modified:tests/test_requests.py+5 added
798 unmodified lines
799 def test_empty_response(self):800 r = requests.get(httpbin('status', '404'))801 r.text802803 def test_no_content(self):804 r = requests.get(httpbin('status', "0"), config={"safe_mode":True})805 r.content806 r.content807808if __name__ == '__main__':809 unittest.main()
modified:AUTHORS.rst+2 added-1 removed
90 unmodified lines
91- Nick Chadwick92- Jonathan Drosdeck93- Jiri Machalek94- Steve Pulec95- Michael Kelly95- Michael Kelly96- Michael Newman <newmaniese@gmail.com>