about summary refs log tree commit diff stats
path: root/ui-snapshot.c
diff options
context:
space:
mode:
authorJohn Keeping2015-08-14 12:47:08 +0100
committerJason A. Donenfeld2015-08-14 15:46:51 +0200
commit58e827cbd9811500f72bf25b1db569b208661618 (patch)
tree24c7e6bb0303d86b6b013d6eb152152fac6b7fd7 /ui-snapshot.c
parentpatch: use cgit_print_error_page() for HTTP status codes (diff)
downloadcgit-58e827cbd9811500f72bf25b1db569b208661618.tar.gz
cgit-58e827cbd9811500f72bf25b1db569b208661618.zip
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>
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r--ui-snapshot.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c index bf4bcd7..9bcf13d 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c
@@ -112,11 +112,13 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
112 unsigned char sha1[20]; 112 unsigned char sha1[20];
113 113
114 if (get_sha1(hex, sha1)) { 114 if (get_sha1(hex, sha1)) {
115 cgit_print_error("Bad object id: %s", hex); 115 cgit_print_error_page(404, "Not found",
116 "Bad object id: %s", hex);
116 return 1; 117 return 1;
117 } 118 }
118 if (!lookup_commit_reference(sha1)) { 119 if (!lookup_commit_reference(sha1)) {
119 cgit_print_error("Not a commit reference: %s", hex); 120 cgit_print_error_page(400, "Bad request",
121 "Not a commit reference: %s", hex);
120 return 1; 122 return 1;
121 } 123 }
122 ctx.page.etag = sha1_to_hex(sha1); 124 ctx.page.etag = sha1_to_hex(sha1);