[PATCH v2 08/22] snapshot: use cgit_print_error_page() for HTTP status codes

John Keeping john at keeping.me.uk
Fri Aug 14 13:47:08 CEST 2015


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 at keeping.me.uk>
---
 ui-snapshot.c | 6 ++++--
 1 file 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,
 	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);
-- 
2.5.0.466.g9af26fa



More information about the CGit mailing list