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

Use errors.HttpProcessingError.message as HTTP error reason and message. #459

Merged
merged 1 commit into from
Aug 7, 2015
Merged
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
12 changes: 8 additions & 4 deletions aiohttp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ def start(self):
except errors.HttpProcessingError as exc:
if self.transport is not None:
yield from self.handle_error(exc.code, message,
None, exc, exc.headers)
None, exc, exc.headers,
exc.message)
except errors.LineLimitExceededParserError as exc:
yield from self.handle_error(400, message, None, exc)
except Exception as exc:
Expand Down Expand Up @@ -316,8 +317,8 @@ def start(self):
# connection is closed
return

def handle_error(self, status=500,
message=None, payload=None, exc=None, headers=None):
def handle_error(self, status=500, message=None,
payload=None, exc=None, headers=None, reason=None):
"""Handle errors.

Returns http response with specific status code. Logs additional
Expand All @@ -332,7 +333,10 @@ def handle_error(self, status=500,
self.log_exception("Error handling request")

try:
reason, msg = RESPONSES[status]
if reason is None or reason == '':
reason, msg = RESPONSES[status]
else:
msg = reason
except KeyError:
status = 500
reason, msg = '???', ''
Expand Down