-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
response return value runtime check #3321
Changes from 14 commits
26feed4
0875f7a
f6b81b3
107228f
2778c4c
0357c16
634c7ce
e350cb6
93395eb
681c2ff
bf3312e
6ab7a49
3acb45a
8d585c8
b1fb855
3f6020b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Bracket IPv6 addresses in the HOST header |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Make server access log format placeholder %b documentation reflect | ||
behavior and docstring. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
from .tcp_helpers import tcp_cork, tcp_keepalive, tcp_nodelay | ||
from .web_exceptions import HTTPException | ||
from .web_request import BaseRequest | ||
from .web_response import Response | ||
from .web_response import Response, StreamResponse | ||
|
||
|
||
__all__ = ('RequestHandler', 'RequestPayloadError', 'PayloadAccessError') | ||
|
@@ -346,6 +346,7 @@ async def start(self): | |
handler = self._task_handler | ||
manager = self._manager | ||
keepalive_timeout = self._keepalive_timeout | ||
resp = None | ||
|
||
while not self._force_close: | ||
if not self._messages: | ||
|
@@ -389,6 +390,12 @@ async def start(self): | |
"please raise the exception instead", | ||
DeprecationWarning) | ||
|
||
if self.debug: | ||
if not isinstance(resp, StreamResponse): | ||
self.log_debug("Possibly missing return " | ||
"statement on request handler") | ||
raise RuntimeError('Web-handler should \ | ||
return a response instance, got {!r}'.format(resp)) | ||
await resp.prepare(request) | ||
await resp.write_eof() | ||
|
||
|
@@ -438,7 +445,7 @@ async def start(self): | |
self.log_exception('Unhandled exception', exc_info=exc) | ||
self.force_close() | ||
finally: | ||
if self.transport is None: | ||
if self.transport is None and resp is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for the check, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this check prevents the maybe there's a way to test it w/o relying on the last There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got you.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, that runtimeError will be bypassed by this one: https:/aio-libs/aiohttp/pull/3321/files/8d585c826f9fb6fc82a5291f5973caf136aaabee#diff-8ac506a3012476288a758f156ca7d7b2R439 another reason why I used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. Agree |
||
self.log_debug('Ignored premature client disconnection.') | ||
elif not self._force_close: | ||
if self._keepalive and not self._close: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace
\
with implicit strings concatenation as a line above.