Skip to content

Commit

Permalink
Merge pull request #382 from AkhilmsAchu/master
Browse files Browse the repository at this point in the history
Make use of ident while showing server error (generated by waitress)
  • Loading branch information
digitalresistor committed Jan 23, 2023
2 parents 6c11b49 + 3b0e7d6 commit bf2b854
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit bf2b854

Please sign in to comment.