Improve documentation, cleanup duplicated code
This commit is contained in:
@@ -3,8 +3,6 @@ import os
|
||||
import sys
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
from time import mktime
|
||||
from wsgiref.handlers import format_date_time
|
||||
|
||||
from httplib import parser
|
||||
from httplib.exceptions import NotFound, Forbidden, NotModified
|
||||
@@ -62,14 +60,6 @@ class AbstractCommand(ABC):
|
||||
def _conditional_headers(self):
|
||||
pass
|
||||
|
||||
def _get_date(self):
|
||||
"""
|
||||
Returns a string representation of the current date according to RFC 1123.
|
||||
"""
|
||||
now = datetime.now()
|
||||
stamp = mktime(now.timetuple())
|
||||
return format_date_time(stamp)
|
||||
|
||||
@abstractmethod
|
||||
def execute(self):
|
||||
pass
|
||||
@@ -81,7 +71,7 @@ class AbstractCommand(ABC):
|
||||
self._process_conditional_headers()
|
||||
|
||||
message = f"HTTP/1.1 {status} {status_message[status]}\r\n"
|
||||
message += f"Date: {self._get_date()}\r\n"
|
||||
message += f"Date: {parser.get_date()}\r\n"
|
||||
|
||||
content_length = len(body)
|
||||
message += f"Content-Length: {content_length}\r\n"
|
||||
|
Reference in New Issue
Block a user