diff options
author | John Keeping | 2015-08-14 12:47:06 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2015-08-14 15:46:51 +0200 |
commit | 9a06211daacd2fff14c6211bfc8bad856694f0f9 (patch) | |
tree | 78a39c30881353cefae597dc26861eb075a498ad | |
parent | snapshot: use cgit_print_error_page() instead of html_status() (diff) | |
download | cgit-9a06211daacd2fff14c6211bfc8bad856694f0f9.tar.gz cgit-9a06211daacd2fff14c6211bfc8bad856694f0f9.zip |
blob: use cgit_print_error_page() to add HTTP headers
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>
-rw-r--r-- | ui-blob.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ui-blob.c b/ui-blob.c index 388a017..b333f86 100644 --- a/ui-blob.c +++ b/ui-blob.c | |||
@@ -126,12 +126,14 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl | |||
126 | 126 | ||
127 | if (hex) { | 127 | if (hex) { |
128 | if (get_sha1_hex(hex, sha1)) { | 128 | if (get_sha1_hex(hex, sha1)) { |
129 | cgit_print_error("Bad hex value: %s", hex); | 129 | cgit_print_error_page(400, "Bad request", |
130 | "Bad hex value: %s", hex); | ||
130 | return; | 131 | return; |
131 | } | 132 | } |
132 | } else { | 133 | } else { |
133 | if (get_sha1(head, sha1)) { | 134 | if (get_sha1(head, sha1)) { |
134 | cgit_print_error("Bad ref: %s", head); | 135 | cgit_print_error_page(404, "Not found", |
136 | "Bad ref: %s", head); | ||
135 | return; | 137 | return; |
136 | } | 138 | } |
137 | } | 139 | } |
@@ -145,13 +147,15 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl | |||
145 | } | 147 | } |
146 | 148 | ||
147 | if (type == OBJ_BAD) { | 149 | if (type == OBJ_BAD) { |
148 | cgit_print_error("Bad object name: %s", hex); | 150 | cgit_print_error_page(404, "Not found", |
151 | "Bad object name: %s", hex); | ||
149 | return; | 152 | return; |
150 | } | 153 | } |
151 | 154 | ||
152 | buf = read_sha1_file(sha1, &type, &size); | 155 | buf = read_sha1_file(sha1, &type, &size); |
153 | if (!buf) { | 156 | if (!buf) { |
154 | cgit_print_error("Error reading object %s", hex); | 157 | cgit_print_error_page(500, "Internal server error", |
158 | "Error reading object %s", hex); | ||
155 | return; | 159 | return; |
156 | } | 160 | } |
157 | 161 | ||