Do not set content-type and content-length headers in exceptions. (#1820)

Co-authored-by: L. Kärkkäinen <tronic@users.noreply.github.com>
This commit is contained in:
L. Kärkkäinen 2020-04-26 06:18:59 +03:00 committed by GitHub
parent 9987893963
commit 8abba597a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,10 +45,7 @@ class InvalidUsage(SanicException):
class MethodNotSupported(SanicException): class MethodNotSupported(SanicException):
def __init__(self, message, method, allowed_methods): def __init__(self, message, method, allowed_methods):
super().__init__(message) super().__init__(message)
self.headers = dict() self.headers = {"Allow": ", ".join(allowed_methods)}
self.headers["Allow"] = ", ".join(allowed_methods)
if method in ["HEAD", "PATCH", "PUT", "DELETE"]:
self.headers["Content-Length"] = 0
@add_status_code(500) @add_status_code(500)
@ -101,10 +98,7 @@ class HeaderNotFound(InvalidUsage):
class ContentRangeError(SanicException): class ContentRangeError(SanicException):
def __init__(self, message, content_range): def __init__(self, message, content_range):
super().__init__(message) super().__init__(message)
self.headers = { self.headers = {"Content-Range": f"bytes */{content_range.total}"}
"Content-Type": "text/plain",
"Content-Range": "bytes */%s" % (content_range.total,),
}
@add_status_code(417) @add_status_code(417)