diff options
| author | John Keeping | 2015-08-14 12:47:02 +0100 |
|---|---|---|
| committer | Jason A. Donenfeld | 2015-08-14 15:46:51 +0200 |
| commit | e9b71ae6fe910573156c4632a314b7dbf84d7b64 (patch) | |
| tree | 9a5cc0a7f72fdea70f9076c7d2b81b8b69b0de32 | |
| parent | aec1204a54e3baa12c76db75c2f67696def05eb0 (diff) | |
| download | cgit-e9b71ae6fe910573156c4632a314b7dbf84d7b64.tar.gz cgit-e9b71ae6fe910573156c4632a314b7dbf84d7b64.tar.bz2 cgit-e9b71ae6fe910573156c4632a314b7dbf84d7b64.zip | |
cgit: use cgit_print_error_page() where appropriate
These are more-or-less one-to-one translations but in the final hunk we
gain an HTTP error code where we used to send "200 OK", which is an
improvement.
Signed-off-by: John Keeping <john@keeping.me.uk>
| -rw-r--r-- | cgit.c | 27 |
1 files changed, 7 insertions, 20 deletions
| @@ -614,13 +614,8 @@ static int prepare_repo_cmd(void) | |||
| 614 | if (get_sha1(ctx.qry.head, sha1)) { | 614 | if (get_sha1(ctx.qry.head, sha1)) { |
| 615 | char *tmp = xstrdup(ctx.qry.head); | 615 | char *tmp = xstrdup(ctx.qry.head); |
| 616 | ctx.qry.head = ctx.repo->defbranch; | 616 | ctx.qry.head = ctx.repo->defbranch; |
| 617 | ctx.page.status = 404; | 617 | cgit_print_error_page(404, "Not found", |
| 618 | ctx.page.statusmsg = "Not found"; | 618 | "Invalid branch: %s", tmp); |
| 619 | cgit_print_http_headers(); | ||
| 620 | cgit_print_docstart(); | ||
| 621 | cgit_print_pageheader(); | ||
| 622 | cgit_print_error("Invalid branch: %s", tmp); | ||
| 623 | cgit_print_docend(); | ||
| 624 | free(tmp); | 619 | free(tmp); |
| 625 | return 1; | 620 | return 1; |
| 626 | } | 621 | } |
| @@ -713,18 +708,13 @@ static void process_request(void) | |||
| 713 | cmd = cgit_get_cmd(); | 708 | cmd = cgit_get_cmd(); |
| 714 | if (!cmd) { | 709 | if (!cmd) { |
| 715 | ctx.page.title = "cgit error"; | 710 | ctx.page.title = "cgit error"; |
| 716 | ctx.page.status = 404; | 711 | cgit_print_error_page(404, "Not found", "Invalid request"); |
| 717 | ctx.page.statusmsg = "Not found"; | ||
| 718 | cgit_print_http_headers(); | ||
| 719 | cgit_print_docstart(); | ||
| 720 | cgit_print_pageheader(); | ||
| 721 | cgit_print_error("Invalid request"); | ||
| 722 | cgit_print_docend(); | ||
| 723 | return; | 712 | return; |
| 724 | } | 713 | } |
| 725 | 714 | ||
| 726 | if (!ctx.cfg.enable_http_clone && cmd->is_clone) { | 715 | if (!ctx.cfg.enable_http_clone && cmd->is_clone) { |
| 727 | html_status(404, "Not found", 0); | 716 | ctx.page.title = "cgit error"; |
| 717 | cgit_print_error_page(404, "Not found", "Invalid request"); | ||
| 728 | return; | 718 | return; |
| 729 | } | 719 | } |
| 730 | 720 | ||
| @@ -735,11 +725,8 @@ static void process_request(void) | |||
| 735 | ctx.qry.vpath = cmd->want_vpath ? ctx.qry.path : NULL; | 725 | ctx.qry.vpath = cmd->want_vpath ? ctx.qry.path : NULL; |
| 736 | 726 | ||
| 737 | if (cmd->want_repo && !ctx.repo) { | 727 | if (cmd->want_repo && !ctx.repo) { |
| 738 | cgit_print_http_headers(); | 728 | cgit_print_error_page(400, "Bad request", |
| 739 | cgit_print_docstart(); | 729 | "No repository selected"); |
| 740 | cgit_print_pageheader(); | ||
| 741 | cgit_print_error("No repository selected"); | ||
| 742 | cgit_print_docend(); | ||
| 743 | return; | 730 | return; |
| 744 | } | 731 | } |
| 745 | 732 | ||
