all repos — cgit @ fd00e71ab7cf1eabd8d1fc2e5980055350849034

a hyperfast web frontend for git written in c

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

fd00e71ab7cf1eabd8d1fc2e5980055350849034

parent

58e827cbd9811500f72bf25b1db569b208661618

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

jump to
M ui-snapshot.cui-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 @@ const struct cgit_snapshot_format* f;

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