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

Make use of ident while showing server error (generated by waitress) #382

Merged
merged 3 commits into from Jan 23, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/waitress/task.py
Expand Up @@ -345,8 +345,9 @@ class ErrorTask(Task):
complete = True

def execute(self):
ident = self.channel.server.adj.ident
e = self.request.error
status, headers, body = e.to_response()
status, headers, body = e.to_response(ident)
self.status = status
self.response_headers.extend(headers)
# We need to explicitly tell the remote client we are closing the
Expand Down
5 changes: 3 additions & 2 deletions src/waitress/utilities.py
Expand Up @@ -258,10 +258,11 @@ class Error:
def __init__(self, body):
self.body = body

def to_response(self):
def to_response(self, ident=None):
status = f"{self.code} {self.reason}"
body = f"{self.reason}\r\n\r\n{self.body}"
tag = "\r\n\r\n(generated by waitress)"
ident = ident if ident else "server"
tag = f"\r\n\r\n(generated by {ident})"
body = (body + tag).encode("utf-8")
headers = [("Content-Type", "text/plain; charset=utf-8")]

Expand Down