all repos — cgit @ 58e827cbd9811500f72bf25b1db569b208661618

a hyperfast web frontend for git written in c

snapshot: use cgit_print_error_page() for HTTP status codes

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>
John Keeping john@keeping.me.uk
Fri, 14 Aug 2015 12:47:08 +0100
commit

58e827cbd9811500f72bf25b1db569b208661618

parent

e3e41e5125b1ce270b5afb42beb83e14c0f350cb

1 files changed, 4 insertions(+), 2 deletions(-)

jump to
M ui-snapshot.cui-snapshot.c

@@ -112,11 +112,13 @@ {

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);