This commit is contained in:
2021-03-25 12:16:40 +01:00
parent 7639383782
commit edfdc94747
5 changed files with 42 additions and 11 deletions

View File

@@ -28,20 +28,41 @@ class IncompleteResponse(HTTPException):
def __init(self, cause):
self.cause = cause
class HTTPServerException(Exception):
""" Base class for HTTP Server exceptions """
status_code: str
message: str
class BadRequest(HTTPServerException):
""" Malformed HTTP request"""
status_code = 400
message = "Bad Request"
class MethodNotAllowed(HTTPServerException):
""" Method is not allowed """
status_code = 405
message = "Method Not Allowed"
def __init(self, allowed_methods):
self.allowed_methods = allowed_methods
class InternalServerError(HTTPServerException):
""" Internal Server Error """
status_code = 500
message = "Internal Server Error"
class NotImplemented(HTTPServerException):
""" Functionality not implemented """
status_code = 501
message = "Not Implemented"
class NotFound(HTTPServerException):
""" Resource not found """
""" Resource not found """
status_code = 404
message = "Not Found"

View File

@@ -97,8 +97,6 @@ class ContentLengthRetriever(Retriever):
cur_payload_size += len(buffer)
yield buffer
return b""
class RawRetriever(Retriever):