Skip to content

Commit

Permalink
Drop ClientResponse.message attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Sep 17, 2015
1 parent 50de921 commit 5257fae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ CHANGES
- Default `response_factory` in `app.router.add_static` now is
`StreamResponse`, not `None`. The functionality is not changed if
default is not specified.

- Drop `ClientResponse.message` attribute, it was always implementation detail.
20 changes: 10 additions & 10 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,14 @@ def terminate(self):

class ClientResponse:

message = None # RawResponseMessage object

# from the Status-Line of the response
version = None # HTTP-Version
status = None # Status-Code
reason = None # Reason-Phrase

cookies = None # Response cookies (Set-Cookie)
content = None # Payload stream
headers = None # Response headers, CIMultiDictProxy

_connection = None # current connection
flow_control_class = FlowControlStreamReader # reader flow control
Expand All @@ -537,11 +536,11 @@ def __init__(self, method, url, host='', *, writer=None, continue100=None):
self.method = method
self.url = url
self.host = host
self.headers = None
self._content = None
self._writer = writer
self._continue = continue100
self._closed = False
self._should_close = True # override by message.should_close later

def _post_init(self, loop):
self._loop = loop
Expand Down Expand Up @@ -591,26 +590,27 @@ def start(self, connection, read_until_eof=False):
httpstream = self._reader.set_parser(self._response_parser)

# read response
self.message = yield from httpstream.read()
if self.message.code != 100:
message = yield from httpstream.read()
if message.code != 100:
break

if self._continue is not None and not self._continue.done():
self._continue.set_result(True)
self._continue = None

# response status
self.version = self.message.version
self.status = self.message.code
self.reason = self.message.reason
self.version = message.version
self.status = message.code
self.reason = message.reason
self._should_close = message.should_close

# headers
self.headers = CIMultiDictProxy(self.message.headers)
self.headers = CIMultiDictProxy(message.headers)

# payload
response_with_body = self.method.lower() != 'head'
self._reader.set_parser(
aiohttp.HttpPayloadParser(self.message,
aiohttp.HttpPayloadParser(message,
readall=read_until_eof,
response_with_body=response_with_body),
self.content)
Expand Down
8 changes: 2 additions & 6 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,10 @@ def _release(self, key, req, transport, protocol, *, should_close=False):
resp = req.response

if not should_close:
if resp is not None:
if resp.message is None:
should_close = True
else:
should_close = resp.message.should_close

if self._force_close:
should_close = True
elif resp is not None:
should_close = resp._should_close

reader = protocol.reader
if should_close or (reader.output and not reader.output.at_eof()):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def test_release(self):
conn._start_cleanup_task = unittest.mock.Mock()
req = unittest.mock.Mock()
resp = req.response = unittest.mock.Mock()
resp.message.should_close = False
resp._should_close = False

tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
key = 1
Expand Down

0 comments on commit 5257fae

Please sign in to comment.