Fix some issues, improve documentation

This commit is contained in:
2021-03-27 19:05:09 +01:00
parent 0f7d67c98d
commit 9036755a62
8 changed files with 89 additions and 48 deletions

View File

@@ -75,7 +75,7 @@ class AbstractCommand(ABC):
self._process_conditional_headers()
message = f"HTTP/1.1 {status} {status_message[status]}\r\n"
message += self._get_date() + "\r\n"
message += f"Date: {self._get_date()}\r\n"
content_length = len(body)
message += f"Content-Length: {content_length}\r\n"
@@ -107,7 +107,7 @@ class AbstractCommand(ABC):
path = root + norm_path
if check and not os.path.exists(path):
raise NotFound()
raise NotFound(path)
return path
@@ -131,7 +131,7 @@ class AbstractCommand(ABC):
return True
if modified <= min_date:
raise NotModified()
raise NotModified(f"{modified} <= {min_date}")
return True
@@ -149,11 +149,11 @@ class AbstractModifyCommand(AbstractCommand, ABC):
def execute(self):
path = self._get_path(False)
dir = os.path.dirname(path)
directory = os.path.dirname(path)
if not os.path.exists(dir):
if not os.path.exists(directory):
raise Forbidden("Target directory does not exists!")
if os.path.exists(dir) and not os.path.isdir(dir):
if os.path.exists(directory) and not os.path.isdir(directory):
raise Forbidden("Target directory is an existing file!")
exists = os.path.exists(path)