small fixes
This commit is contained in:
@@ -31,6 +31,15 @@ class AbstractCommand(ABC):
|
||||
else:
|
||||
raise ValueError()
|
||||
|
||||
|
||||
@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):
|
||||
(host, path) = self.parse_uri()
|
||||
|
||||
@@ -40,7 +49,6 @@ class AbstractCommand(ABC):
|
||||
message = f"{self.command} {path} HTTP/1.1\r\n"
|
||||
message += f"Host: {host}\r\n"
|
||||
message += "Accept: */*\r\nAccept-Encoding: identity\r\n"
|
||||
message += "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0\r\n"
|
||||
encoded_msg = self._build_message(message)
|
||||
|
||||
logging.info("---request begin---\r\n%s---request end---", encoded_msg.decode(FORMAT))
|
||||
@@ -94,6 +102,9 @@ 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()
|
||||
|
Reference in New Issue
Block a user