Skip to content

Commit

Permalink
Fix #1400
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Dec 7, 2016
1 parent 004ae3f commit 6fb5c7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aiohttp/web_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ def __init__(self, *, body=None, status=200,
super().__init__(status=status, reason=reason, headers=headers)
if text is not None:
self.text = text
elif body is None and hdrs.CONTENT_LENGTH in headers:
self._body = None
else:
self.body = body

Expand Down
5 changes: 5 additions & 0 deletions tests/test_web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,11 @@ def test_text_with_empty_payload():
assert resp.text is None


def test_response_with_content_length_header_without_body():
resp = Response(headers={'Content-Length': 123})
assert resp.content_length == 123


class TestJSONResponse:

def test_content_type_is_application_json_by_default(self):
Expand Down

0 comments on commit 6fb5c7c

Please sign in to comment.