diff options
author | Frederick Yin <fkfd@macaw.me> | 2020-07-10 19:27:16 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@macaw.me> | 2020-07-10 19:27:16 +0800 |
commit | eb1bd1e074b81a428cb689d3a381e86e2fd530dd (patch) | |
tree | 8f93cacdc86723abbc27717dccc1b4ea42cdeb95 /git-gmi | |
parent | b5b74573fe2a6c8030122ff6574603c8e3668c85 (diff) |
Fix: response headers now terminate with CRLF
Diffstat (limited to 'git-gmi')
-rw-r--r-- | git-gmi/git.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/git-gmi/git.py b/git-gmi/git.py index 9e76b2d..3de904e 100644 --- a/git-gmi/git.py +++ b/git-gmi/git.py @@ -36,7 +36,7 @@ class GitGmiRepo: return header def view_summary(self) -> str: - response = f"{STATUS_SUCCESS} {META_GEMINI}\n" + self.generate_header() + response = f"{STATUS_SUCCESS} {META_GEMINI}\r\n" + self.generate_header() # show 3 recent commits recent_commits = self.get_commit_log()[:3] for cmt in recent_commits: @@ -82,7 +82,7 @@ class GitGmiRepo: return log # reverse chronical order def view_log(self) -> str: - response = f"{STATUS_SUCCESS} {META_GEMINI}\n" + self.generate_header() + response = f"{STATUS_SUCCESS} {META_GEMINI}\r\n" + self.generate_header() log = self.get_commit_log() for cmt in log: # looks like "2020-06-06 04:51:21 UTC" @@ -112,7 +112,7 @@ class GitGmiRepo: def view_commit(self, commit_str) -> str: commit = self.get_commit(commit_str) response = ( - f"{STATUS_SUCCESS} {META_GEMINI}\n" + f"{STATUS_SUCCESS} {META_GEMINI}\r\n" + self.generate_header() + f"{commit['id']} - {commit['author']} - {commit['time']}\n" + commit["msg"] @@ -127,7 +127,7 @@ class GitGmiRepo: def view_raw_commit(self, commit_str) -> str: commit = self.get_commit(commit_str) - response = f"{STATUS_SUCCESS} {META_PLAINTEXT}\n" + commit["patch"] + response = f"{STATUS_SUCCESS} {META_PLAINTEXT}\r\n" + commit["patch"] return response def get_refs(self) -> list: @@ -143,7 +143,7 @@ class GitGmiRepo: ] def view_refs(self) -> str: - response = f"{STATUS_SUCCESS} {META_GEMINI}\n" + self.generate_header() + response = f"{STATUS_SUCCESS} {META_GEMINI}\r\n" + self.generate_header() refs = self.get_refs() for ref in refs: # HACK: filter out refs with slashes as remote branches @@ -229,7 +229,7 @@ class GitGmiRepo: contents = self.list_tree(tree, location) items = len(contents) response = ( - f"{STATUS_SUCCESS} {META_GEMINI}\n" + f"{STATUS_SUCCESS} {META_GEMINI}\r\n" + self.generate_header() + f"## {self.name}{'/' if location else ''}{'/'.join(location)}/" f" | {items} {'items' if items > 1 else 'item'}\n\n" @@ -260,7 +260,7 @@ class GitGmiRepo: def view_blob(self, branch: str, location=[]) -> str: blob = self.get_blob(branch, location) response = ( - f"{STATUS_SUCCESS} {META_GEMINI}\n" + f"{STATUS_SUCCESS} {META_GEMINI}\r\n" + self.generate_header() + f"## {self.name}/{'/'.join(location)} | {convert_filesize(blob.size)}\n\n" f"=> {blob.name}?raw view raw\n\n" @@ -273,6 +273,6 @@ class GitGmiRepo: blob = self.get_blob(branch, location) # if mimetypes can't make out the type, set it to plaintext guessed_mimetype = mimetypes.guess_type(blob.name)[0] or META_PLAINTEXT - response = f"{STATUS_SUCCESS} {guessed_mimetype}\n" + response = f"{STATUS_SUCCESS} {guessed_mimetype}\r\n" response += blob.data.decode("utf-8") return response |