Diff options
Diffstat (limited to 'tools')
-rwxr-xr-xtools/serve.py15
1 file changed, 5 insertions, 10 deletions
diff --git a/tools/serve.py b/tools/serve.py
index 8924e53..492345e 100755
--- a/tools/serve.py
+++ b/tools/serve.py
@@ -65,12 +65,9 @@ def split_cgi_output(output: bytes) -> CgiResponse:
The header block ends at the first blank line. cgit ends its lines with a
bare LF while a filter writing its own headers may use CRLF, so whichever
- terminator appears earliest is the real one. Looking for CRLF everywhere
- before falling back to LF would instead find the first CRLF in the body,
- and a commit message with DOS line endings has one, which swallowed the
- whole document head into the headers. Splitting on the separator rather
- than on a non-empty body keeps a legitimately empty body, such as the one
- a redirect leaves behind, from being read as headers.
+ terminator appears earliest is the real one, and a later blank line of the
+ other kind, such as one in a commit message with DOS line endings, belongs
+ to the body. The body may also be empty, as a redirect leaves it.
"""
ends = [(at, len(sep)) for sep in (b"\r\n\r\n", b"\n\n") if (at := output.find(sep)) >= 0]
if ends:
@@ -233,8 +230,6 @@ class CgitHandler(BaseHTTPRequestHandler):
_ = self.wfile.write(response.body)
def log_message(self, format: str, *args: object) -> None:
- # The signature matches BaseHTTPRequestHandler, so the parameter here
- # shadows the builtin of the same name.
_ = sys.stderr.write(f" {format % args}\n")
@@ -262,14 +257,14 @@ class Options(argparse.Namespace):
data: str = str(REPO_ROOT / "assets")
-def parse_args(argv: list[str] | None = None) -> Options:
+def parse_args() -> Options:
parser = argparse.ArgumentParser(description="Preview cgit locally.")
_ = parser.add_argument("--config", default=Options.config, help="path to cgitrc (default: ./cgitrc)")
_ = parser.add_argument("--port", type=int, default=Options.port)
_ = parser.add_argument("--host", default=Options.host)
_ = parser.add_argument("--cgit", default=Options.cgit, help="path to the cgit binary")
_ = parser.add_argument("--data", default=Options.data, help="directory holding cgit.css, cgit.js, images")
- return parser.parse_args(argv, namespace=Options())
+ return parser.parse_args(namespace=Options())
def main() -> None: