Skip to content

Commit

Permalink
Fix access log formats %O and %b for static file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Sep 16, 2016
1 parent ce4c0e0 commit 0922176
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ CHANGES

- Fix `AssertionError` in static file handling #1177

- Fix access log formats `%O` and `%b` for static file handling


1.0.0 (2016-09-16)
-------------------
Expand Down
13 changes: 7 additions & 6 deletions aiohttp/file_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ def write_eof():

resp.write_eof = write_eof

yield from resp.prepare(request)

# TODO: %O and %b (resp_impl.output_length and resp_impl.output)
# access log formats are broken
resp_impl = yield from resp.prepare(request)

loop = request.app.loop
# See https://github.com/KeepSafe/aiohttp/issues/958 for details
Expand All @@ -95,9 +92,13 @@ def write_eof():
out_fd = out_socket.fileno()
in_fd = fobj.fileno()

bheaders = ''.join(headers).encode('utf-8')
headers_length = len(bheaders)
resp_impl.headers_length = headers_length
resp_impl.output_length = headers_length + count

try:
yield from loop.sock_sendall(out_socket,
''.join(headers).encode('utf-8'))
yield from loop.sock_sendall(out_socket, bheaders)
fut = create_future(loop)
self._sendfile_cb(fut, out_fd, in_fd, 0, count, loop, False)

Expand Down

0 comments on commit 0922176

Please sign in to comment.