Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #271: Memory leak in request #723

Merged
merged 1 commit into from
Jan 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CHANGES
=======

0.21.0 (XX-XX-XXXX)
0.20.2 (01-07-2015)
--------------------

- Enable use of `await` for a class based view #717
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This relies on each of the submodules having an __all__ variable.

__version__ = '0.21.0a0'
__version__ = '0.20.2'


from . import hdrs # noqa
Expand Down
6 changes: 2 additions & 4 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,8 @@ def send(self, writer, reader):
hdrs.CONTENT_TYPE not in self.headers):
self.headers[hdrs.CONTENT_TYPE] = 'application/octet-stream'

request.add_headers(
*((k, v)
for k, v in ((k, value)
for k, value in self.headers.items())))
for k, value in self.headers.items():
request.add_header(k, value)
request.send_headers()

self._writer = helpers.ensure_future(
Expand Down
6 changes: 2 additions & 4 deletions aiohttp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import collections
import functools
import http.server
import itertools
import re
import string
import sys
Expand Down Expand Up @@ -661,9 +660,8 @@ def send_headers(self, _sep=': ', _end='\r\n'):
self._add_default_headers()

# status + headers
headers = ''.join(itertools.chain(
(self.status_line,),
*((k, _sep, v, _end) for k, v in self.headers.items())))
headers = self.status_line + ''.join(
[k + _sep + v + _end for k, v in self.headers.items()])
headers = headers.encode('utf-8') + b'\r\n'

self.output_length += len(headers)
Expand Down
13 changes: 6 additions & 7 deletions aiohttp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ def handle_error(self, status=500, message=None,
status=status, reason=reason, message=msg).encode('utf-8')

response = aiohttp.Response(self.writer, status, close=True)
response.add_headers(
('CONTENT-TYPE', 'text/html; charset=utf-8'),
('CONTENT-LENGTH', str(len(html))))
response.add_header(hdrs.CONTENT_TYPE, 'text/html; charset=utf-8')
response.add_header(hdrs.CONTENT_LENGTH, str(len(html)))
if headers is not None:
response.add_headers(*headers)
for name, value in headers:
response.add_header(name, value)
response.send_headers()

response.write(html)
Expand Down Expand Up @@ -385,9 +385,8 @@ def handle_request(self, message, payload):

body = b'Page Not Found!'

response.add_headers(
('CONTENT-TYPE', 'text/plain'),
('CONTENT-LENGTH', str(len(body))))
response.add_header(hdrs.CONTENT_TYPE, 'text/plain')
response.add_header(hdrs.CONTENT_LENGTH, str(len(body)))
response.send_headers()
response.write(body)
drain = response.write_eof()
Expand Down
3 changes: 2 additions & 1 deletion aiohttp/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ def start_response(self, status, headers, exc_info=None):
self.writer, status_code,
self.message.version, self.message.should_close)
resp.HOP_HEADERS = self.HOP_HEADERS
resp.add_headers(*headers)
for name, value in headers:
resp.add_header(name, value)

if resp.has_chunked_hdr:
resp.enable_chunked_encoding()
Expand Down