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:
parent
9987893963
commit
8abba597a8
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user