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

@@ -1,18 +1,35 @@
from abc import ABC
from typing import Dict
from urllib.parse import SplitResult
class Message:
class Message(ABC):
version: str
status: int
msg: str
headers: Dict[str, str]
raw: str
body: bytes
def __init__(self, version: str, status: int, msg: str, headers: Dict[str, str], raw=None, body: bytes = None):
def __init__(self, version: str, headers: Dict[str, str], raw=None, body: bytes = None):
self.version = version
self.status = status
self.msg = msg
self.headers = headers
self.raw = raw
self.body = body
class ClientMessage(Message):
status: int
msg: str
def __init__(self, version: str, status: int, msg: str, headers: Dict[str, str], raw=None, body: bytes = None):
super().__init__(version, headers, raw, body)
self.status = status
class ServerMessage(Message):
method: str
target: SplitResult
def __init__(self, version: str, method: str, target, headers: Dict[str, str], raw=None, body: bytes = None):
super().__init__(version, headers, raw, body)
self.method = method
self.target = target