]> gitweb.ps.run Git - ps-cgit/commitdiff
snapshot: use cgit_print_error_page() for HTTP status codes
authorJohn Keeping <john@keeping.me.uk>
Fri, 14 Aug 2015 11:47:08 +0000 (12:47 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 14 Aug 2015 13:46:51 +0000 (15:46 +0200)
This is a bugfix as well as an improvement to the HTTP status code
handling since previously we would not print HTTP headers on any of
these code paths.

Signed-off-by: John Keeping <john@keeping.me.uk>
ui-snapshot.c

index bf4bcd7b6fa9d90bbeadc6a6f548954bfe3134e2..9bcf13d2b835d8c4536a2986b17f5a622d725418 100644 (file)
@@ -112,11 +112,13 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
        unsigned char sha1[20];
 
        if (get_sha1(hex, sha1)) {
-               cgit_print_error("Bad object id: %s", hex);
+               cgit_print_error_page(404, "Not found",
+                               "Bad object id: %s", hex);
                return 1;
        }
        if (!lookup_commit_reference(sha1)) {
-               cgit_print_error("Not a commit reference: %s", hex);
+               cgit_print_error_page(400, "Bad request",
+                               "Not a commit reference: %s", hex);
                return 1;
        }
        ctx.page.etag = sha1_to_hex(sha1);