about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2015-08-14 12:47:09 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2015-08-14 15:46:51 +0200
commitfd00e71ab7cf1eabd8d1fc2e5980055350849034 (patch)
tree0f206d7e919bcd301f17278fd0e9c37fb2559a12
parentsnapshot: use cgit_print_error_page() for HTTP status codes (diff)
downloadcgit-pink-fd00e71ab7cf1eabd8d1fc2e5980055350849034.tar.gz
cgit-pink-fd00e71ab7cf1eabd8d1fc2e5980055350849034.zip
snapshot: don't reimplement cgit_print_error_page()
cgit_print_error_page() has the advantage that it sets a suitable HTTP
status code for the response.  Note that setting "mimetype" is redundant
here since it cannot have changed since being initialized in
cgit.c::prepare_context(), so we do not need to worry that
cgit_print_error_page() does not set it.

Signed-off-by: John Keeping <john@keeping.me.uk>
-rw-r--r--ui-snapshot.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 9bcf13d..f68e877 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -180,21 +180,6 @@ out:
 	return result ? strbuf_detach(&snapshot, NULL) : NULL;
 }
 
-__attribute__((format (printf, 1, 2)))
-static void show_error(char *fmt, ...)
-{
-	va_list ap;
-
-	ctx.page.mimetype = "text/html";
-	cgit_print_http_headers();
-	cgit_print_docstart();
-	cgit_print_pageheader();
-	va_start(ap, fmt);
-	cgit_vprint_error(fmt, ap);
-	va_end(ap);
-	cgit_print_docend();
-}
-
 void cgit_print_snapshot(const char *head, const char *hex,
 			 const char *filename, int dwim)
 {
@@ -202,13 +187,15 @@ void cgit_print_snapshot(const char *head, const char *hex,
 	char *prefix = NULL;
 
 	if (!filename) {
-		show_error("No snapshot name specified");
+		cgit_print_error_page(400, "Bad request",
+				"No snapshot name specified");
 		return;
 	}
 
 	f = get_format(filename);
 	if (!f) {
-		show_error("Unsupported snapshot format: %s", filename);
+		cgit_print_error_page(400, "Bad request",
+				"Unsupported snapshot format: %s", filename);
 		return;
 	}
 
76755b98bb597279a1930bf4c69eca7dde62&follow=1'>filter: don't use dlsym unnecessarilyJohn Keeping 2015-08-13ui-tree: use "sane" isgraph()John Keeping 2015-08-13cgit.h: move stdbool.h from ui-shared.hJohn Keeping 2015-08-13cache.c: fix header orderJohn Keeping 2015-08-13configfile.c: don't include system headers directlyJohn Keeping 2015-08-13Remove redundant includesJohn Keeping 2015-08-13Makefile: include Git's config.mak.unameJohn Keeping 2015-08-13tests: allow shell to be overriddenJohn Keeping 2015-08-13redirect: cleanlinessJason A. Donenfeld 2015-08-13redirect: be more careful for different cgi setupsJason A. Donenfeld 2015-08-12ui-log: fix double countingJohn Keeping 2015-08-12log: allow users to follow a fileJohn Keeping 2015-08-12shared: make cgit_diff_tree_cb publicJohn Keeping 2015-08-12t0110: Chain together using &&Jason A. Donenfeld 2015-08-12about: always ensure page has a trailing slashJason A. Donenfeld 2015-08-12filters: apply HTML escapingLazaros Koromilas 2015-08-12git: update to v2.5.0Christian Hesse 2015-08-12Fix processing of repo.hide and repo.ignoreDaniel Reichelt