Skip to content

Commit

Permalink
Update CHANGES
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jan 25, 2016
1 parent d8b1cda commit aafe98f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ CHANGES
- Add async context manager support to ClientSession

- Document ClientResponse's host, method, url properties

- Use CORK/NODELAY in client API #748
60 changes: 34 additions & 26 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class RequestHandler(ServerHttpProtocol):

_meth = 'none'
_path = 'none'
_request = None

def __init__(self, manager, app, router, *,
secure_proxy_ssl_header=None, **kwargs):
Expand All @@ -58,6 +59,8 @@ def connection_lost(self, exc):
self._manager.connection_lost(self, exc)

super().connection_lost(exc)
if self._request is not None:
pass

@asyncio.coroutine
def handle_request(self, message, payload):
Expand All @@ -69,35 +72,40 @@ def handle_request(self, message, payload):
app, message, payload,
self.transport, self.reader, self.writer,
secure_proxy_ssl_header=self._secure_proxy_ssl_header)
self._request = request
self._meth = request.method
self._path = request.path
try:
match_info = yield from self._router.resolve(request)

assert isinstance(match_info, AbstractMatchInfo), match_info

resp = None
request._match_info = match_info
expect = request.headers.get(hdrs.EXPECT)
if expect and expect.lower() == "100-continue":
resp = (
yield from match_info.route.handle_expect_header(request))

if resp is None:
handler = match_info.handler
for factory in reversed(self._middlewares):
handler = yield from factory(app, handler)
resp = yield from handler(request)

assert isinstance(resp, StreamResponse), \
("Handler {!r} should return response instance, "
"got {!r} [middlewares {!r}]").format(
match_info.handler, type(resp), self._middlewares)
except HTTPException as exc:
resp = exc

resp_msg = yield from resp.prepare(request)
yield from resp.write_eof()
try:
match_info = yield from self._router.resolve(request)

assert isinstance(match_info, AbstractMatchInfo), match_info

resp = None
request._match_info = match_info
expect = request.headers.get(hdrs.EXPECT)
if expect and expect.lower() == "100-continue":
resp = (
yield from match_info.route.handle_expect_header(
request))

if resp is None:
handler = match_info.handler
for factory in reversed(self._middlewares):
handler = yield from factory(app, handler)
resp = yield from handler(request)

assert isinstance(resp, StreamResponse), \
("Handler {!r} should return response instance, "
"got {!r} [middlewares {!r}]").format(
match_info.handler, type(resp), self._middlewares)
except HTTPException as exc:
resp = exc

resp_msg = yield from resp.prepare(request)
yield from resp.write_eof()
finally:
self._request = None

# notify server about keep-alive
self.keep_alive(resp_msg.keep_alive())
Expand Down

0 comments on commit aafe98f

Please sign in to comment.