This commit is contained in:
2021-03-26 18:25:03 +01:00
parent 7476870acc
commit fdbd865889
11 changed files with 297 additions and 136 deletions

View File

@@ -33,6 +33,10 @@ class HTTPServerException(Exception):
""" Base class for HTTP Server exceptions """
status_code: str
message: str
body: str
def __init__(self, body=""):
self.body = body
class BadRequest(HTTPServerException):
@@ -66,3 +70,28 @@ class NotFound(HTTPServerException):
""" Resource not found """
status_code = 404
message = "Not Found"
class Forbidden(HTTPServerException):
""" Request not allowed """
status_code = 403
message = "Forbidden"
class Conflict(HTTPServerException):
""" Conflict in the current state of the target resource """
status_code = 409
message = "Conflict"
class HTTPVersionNotSupported(HTTPServerException):
""" The server does not support the major version HTTP used in the request message """
status_code = 505
message = "HTTP Version Not Supported"
class InvalidRequestLine(BadRequest):
""" Request start-line is invalid """
def __init__(self, line):
self.request_line = line