diff options
| -rw-r--r-- | source/ui-shared.c | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0107-snapshot.sh | 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 24 insertions, 5 deletions
diff --git a/source/ui-shared.c b/source/ui-shared.c index 110dd91..db441e0 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1089,8 +1089,12 @@ void cgit_print_http_headers(void) if (ctx.env.no_http && !strcmp(ctx.env.no_http, "1")) return; + // CGI treats a missing Status as 200, but writing it keeps every + // response's header block the same shape. if (ctx.page.status) htmlf("Status: %d %s\n", ctx.page.status, ctx.page.statusmsg); + else + html("Status: 200 OK\n"); if (ctx.page.mimetype && ctx.page.charset) htmlf("Content-Type: %s; charset=%s\n", ctx.page.mimetype, ctx.page.charset); diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index 0762ab2..6f5f588 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh @@ -16,9 +16,12 @@ test_expect_success 'get foo/snapshot/master.tar.gz' ' test_expect_success 'check html headers' ' head -n 1 tmp | - grep "Content-Type: application/x-gzip" && + grep "Status: 200 OK" && head -n 2 tmp | + grep "Content-Type: application/x-gzip" && + + head -n 3 tmp | grep "Content-Disposition: inline; filename=.master.tar.gz." ' @@ -57,9 +60,12 @@ test_expect_success LZIP 'get foo/snapshot/master.tar.lz' ' test_expect_success LZIP 'check html headers' ' head -n 1 tmp | - grep "Content-Type: application/x-lzip" && + grep "Status: 200 OK" && head -n 2 tmp | + grep "Content-Type: application/x-lzip" && + + head -n 3 tmp | grep "Content-Disposition: inline; filename=.master.tar.lz." ' @@ -98,9 +104,12 @@ test_expect_success XZ 'get foo/snapshot/master.tar.xz' ' test_expect_success XZ 'check html headers' ' head -n 1 tmp | - grep "Content-Type: application/x-xz" && + grep "Status: 200 OK" && head -n 2 tmp | + grep "Content-Type: application/x-xz" && + + head -n 3 tmp | grep "Content-Disposition: inline; filename=.master.tar.xz." ' @@ -139,9 +148,12 @@ test_expect_success ZSTD 'get foo/snapshot/master.tar.zst' ' test_expect_success ZSTD 'check html headers' ' head -n 1 tmp | - grep "Content-Type: application/x-zstd" && + grep "Status: 200 OK" && head -n 2 tmp | + grep "Content-Type: application/x-zstd" && + + head -n 3 tmp | grep "Content-Disposition: inline; filename=.master.tar.zst." ' @@ -174,9 +186,12 @@ test_expect_success 'get foo/snapshot/master.zip' ' test_expect_success 'check HTML headers (zip)' ' head -n 1 tmp | - grep "Content-Type: application/x-zip" && + grep "Status: 200 OK" && head -n 2 tmp | + grep "Content-Type: application/x-zip" && + + head -n 3 tmp | grep "Content-Disposition: inline; filename=.master.zip." ' |
