-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | ui-shared.c | 2 |
3 files changed, 6 insertions, 0 deletions
@@ -276,24 +276,26 @@ static int prepare_repo_cmd(struct cgit_context *ctx) | |||
276 | if (!ctx->qry.head) { | 276 | if (!ctx->qry.head) { |
277 | cgit_print_http_headers(ctx); | 277 | cgit_print_http_headers(ctx); |
278 | cgit_print_docstart(ctx); | 278 | cgit_print_docstart(ctx); |
279 | cgit_print_pageheader(ctx); | 279 | cgit_print_pageheader(ctx); |
280 | cgit_print_error("Repository seems to be empty"); | 280 | cgit_print_error("Repository seems to be empty"); |
281 | cgit_print_docend(); | 281 | cgit_print_docend(); |
282 | return 1; | 282 | return 1; |
283 | } | 283 | } |
284 | 284 | ||
285 | if (get_sha1(ctx->qry.head, sha1)) { | 285 | if (get_sha1(ctx->qry.head, sha1)) { |
286 | tmp = xstrdup(ctx->qry.head); | 286 | tmp = xstrdup(ctx->qry.head); |
287 | ctx->qry.head = ctx->repo->defbranch; | 287 | ctx->qry.head = ctx->repo->defbranch; |
288 | ctx->page.status = 404; | ||
289 | ctx->page.statusmsg = "not found"; | ||
288 | cgit_print_http_headers(ctx); | 290 | cgit_print_http_headers(ctx); |
289 | cgit_print_docstart(ctx); | 291 | cgit_print_docstart(ctx); |
290 | cgit_print_pageheader(ctx); | 292 | cgit_print_pageheader(ctx); |
291 | cgit_print_error(fmt("Invalid branch: %s", tmp)); | 293 | cgit_print_error(fmt("Invalid branch: %s", tmp)); |
292 | cgit_print_docend(); | 294 | cgit_print_docend(); |
293 | return 1; | 295 | return 1; |
294 | } | 296 | } |
295 | return 0; | 297 | return 0; |
296 | } | 298 | } |
297 | 299 | ||
298 | static void process_request(void *cbdata) | 300 | static void process_request(void *cbdata) |
299 | { | 301 | { |
@@ -172,24 +172,26 @@ struct cgit_config { | |||
172 | int summary_log; | 172 | int summary_log; |
173 | int summary_tags; | 173 | int summary_tags; |
174 | }; | 174 | }; |
175 | 175 | ||
176 | struct cgit_page { | 176 | struct cgit_page { |
177 | time_t modified; | 177 | time_t modified; |
178 | time_t expires; | 178 | time_t expires; |
179 | size_t size; | 179 | size_t size; |
180 | char *mimetype; | 180 | char *mimetype; |
181 | char *charset; | 181 | char *charset; |
182 | char *filename; | 182 | char *filename; |
183 | char *title; | 183 | char *title; |
184 | int status; | ||
185 | char *statusmsg; | ||
184 | }; | 186 | }; |
185 | 187 | ||
186 | struct cgit_context { | 188 | struct cgit_context { |
187 | struct cgit_query qry; | 189 | struct cgit_query qry; |
188 | struct cgit_config cfg; | 190 | struct cgit_config cfg; |
189 | struct cgit_repo *repo; | 191 | struct cgit_repo *repo; |
190 | struct cgit_page page; | 192 | struct cgit_page page; |
191 | }; | 193 | }; |
192 | 194 | ||
193 | struct cgit_snapshot_format { | 195 | struct cgit_snapshot_format { |
194 | const char *suffix; | 196 | const char *suffix; |
195 | const char *mimetype; | 197 | const char *mimetype; |
diff --git a/ui-shared.c b/ui-shared.c index de77bbf..2630f23 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -447,24 +447,26 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
447 | } | 447 | } |
448 | if (secs < TM_YEAR * 2) { | 448 | if (secs < TM_YEAR * 2) { |
449 | htmlf("<span class='age-months'>%.0f months</span>", | 449 | htmlf("<span class='age-months'>%.0f months</span>", |
450 | secs * 1.0 / TM_MONTH); | 450 | secs * 1.0 / TM_MONTH); |
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | htmlf("<span class='age-years'>%.0f years</span>", | 453 | htmlf("<span class='age-years'>%.0f years</span>", |
454 | secs * 1.0 / TM_YEAR); | 454 | secs * 1.0 / TM_YEAR); |
455 | } | 455 | } |
456 | 456 | ||
457 | void cgit_print_http_headers(struct cgit_context *ctx) | 457 | void cgit_print_http_headers(struct cgit_context *ctx) |
458 | { | 458 | { |
459 | if (ctx->page.status) | ||
460 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); | ||
459 | if (ctx->page.mimetype && ctx->page.charset) | 461 | if (ctx->page.mimetype && ctx->page.charset) |
460 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 462 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
461 | ctx->page.charset); | 463 | ctx->page.charset); |
462 | else if (ctx->page.mimetype) | 464 | else if (ctx->page.mimetype) |
463 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 465 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
464 | if (ctx->page.size) | 466 | if (ctx->page.size) |
465 | htmlf("Content-Length: %ld\n", ctx->page.size); | 467 | htmlf("Content-Length: %ld\n", ctx->page.size); |
466 | if (ctx->page.filename) | 468 | if (ctx->page.filename) |
467 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 469 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
468 | ctx->page.filename); | 470 | ctx->page.filename); |
469 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 471 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
470 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 472 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |