update
This commit is contained in:
@@ -78,7 +78,8 @@ class RequestHandler:
|
||||
def _has_body(self, headers):
|
||||
return "transfer-encoding" in headers or "content-encoding" in headers
|
||||
|
||||
def _get_date(self):
|
||||
@staticmethod
|
||||
def _get_date():
|
||||
now = datetime.now()
|
||||
stamp = mktime(now.timetuple())
|
||||
return format_date_time(stamp)
|
||||
@@ -114,3 +115,13 @@ class RequestHandler:
|
||||
|
||||
logging.debug("Sending: %r", message)
|
||||
self.conn.conn.sendall(message)
|
||||
|
||||
@staticmethod
|
||||
def send_error(client: socket, code, message):
|
||||
message = f"HTTP/1.1 {code} {message}\r\n"
|
||||
message += RequestHandler._get_date() + "\r\n"
|
||||
message += "Content-Length: 0\r\n"
|
||||
message += "\r\n"
|
||||
|
||||
logging.debug("Sending: %r", message)
|
||||
client.sendall(message.encode(FORMAT))
|
||||
|
Reference in New Issue
Block a user