server: add commands

This commit is contained in:
2021-03-25 16:43:39 +01:00
parent edfdc94747
commit b37aa33131
3 changed files with 100 additions and 14 deletions

View File

@@ -41,14 +41,6 @@ class AbstractCommand(ABC):
def command(self):
pass
@staticmethod
def build_message(command, host, path):
message = f"{command} {path} HTTP/1.1\r\n"
message += f"Host: {host}\r\n"
message += "Accept: */*\r\nAccept-Encoding: identity\r\n"
return message.encode(FORMAT)
def execute(self, sub_request=False):
(host, path) = self.parse_uri()
@@ -120,10 +112,6 @@ class AbstractCommand(ABC):
class AbstractWithBodyCommand(AbstractCommand, ABC):
@staticmethod
def build_message(command, host, path):
message = AbstractCommand.build_message()
def _build_message(self, message: str) -> bytes:
body = input(f"Enter {self.command} data: ").encode(FORMAT)
print()