Skip to content

Commit

Permalink
Do not set content-type and content-length headers in exceptions. (#1820
Browse files Browse the repository at this point in the history
)

Co-authored-by: L. Kärkkäinen <[email protected]>
  • Loading branch information
Tronic and Tronic authored Apr 26, 2020
1 parent 9987893 commit 8abba59
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions sanic/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ class InvalidUsage(SanicException):
class MethodNotSupported(SanicException):
def __init__(self, message, method, allowed_methods):
super().__init__(message)
self.headers = dict()
self.headers["Allow"] = ", ".join(allowed_methods)
if method in ["HEAD", "PATCH", "PUT", "DELETE"]:
self.headers["Content-Length"] = 0
self.headers = {"Allow": ", ".join(allowed_methods)}


@add_status_code(500)
Expand Down Expand Up @@ -101,10 +98,7 @@ class HeaderNotFound(InvalidUsage):
class ContentRangeError(SanicException):
def __init__(self, message, content_range):
super().__init__(message)
self.headers = {
"Content-Type": "text/plain",
"Content-Range": "bytes */%s" % (content_range.total,),
}
self.headers = {"Content-Range": f"bytes */{content_range.total}"}


@add_status_code(417)
Expand Down

0 comments on commit 8abba59

Please sign in to comment.