Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-void html_status(int code, int more_headers)
+void html_status(int code, const char *msg, int more_headers)
- htmlf("Status: %d\n", code);
+ htmlf("Status: %d %s\n", code, msg);
if (!more_headers)
html("\n");
}
if (!more_headers)
html("\n");
}
extern void html_raw(const char *txt, size_t size);
extern void html(const char *txt);
extern void htmlf(const char *format,...);
extern void html_raw(const char *txt, size_t size);
extern void html(const char *txt);
extern void htmlf(const char *format,...);
-extern void html_status(int code, int more_headers);
+extern void html_status(int code, const char *msg, int more_headers);
extern void html_txt(char *txt);
extern void html_ntxt(int len, char *txt);
extern void html_attr(char *txt);
extern void html_txt(char *txt);
extern void html_ntxt(int len, char *txt);
extern void html_attr(char *txt);
static void send_file(struct cgit_context *ctx, char *path)
{
struct stat st;
static void send_file(struct cgit_context *ctx, char *path)
{
struct stat st;
if (stat(path, &st)) {
switch (errno) {
case ENOENT:
if (stat(path, &st)) {
switch (errno) {
case ENOENT:
+ html_status(404, "Not found", 0);
+ html_status(403, "Forbidden", 0);
+ html_status(400, "Bad request", 0);
return;
}
ctx->page.mimetype = "application/octet-stream";
return;
}
ctx->page.mimetype = "application/octet-stream";
void cgit_clone_objects(struct cgit_context *ctx)
{
if (!ctx->qry.path) {
void cgit_clone_objects(struct cgit_context *ctx)
{
if (!ctx->qry.path) {
+ html_status(400, "Bad request", 0);
type = sha1_object_info(sha1, &size);
if (type == OBJ_BAD) {
type = sha1_object_info(sha1, &size);
if (type == OBJ_BAD) {
+ html_status(404, "Not found", 0);
return;
}
buf = read_sha1_file(sha1, &type, &size);
if (!buf) {
return;
}
buf = read_sha1_file(sha1, &type, &size);
if (!buf) {
+ html_status(404, "Not found", 0);
return;
}
ctx.page.mimetype = "text/plain";
return;
}
ctx.page.mimetype = "text/plain";
curr_rev = xstrdup(rev);
if (get_sha1(rev, sha1)) {
curr_rev = xstrdup(rev);
if (get_sha1(rev, sha1)) {
+ html_status(404, "Not found", 0);
return;
}
commit = lookup_commit_reference(sha1);
if (!commit || parse_commit(commit)) {
return;
}
commit = lookup_commit_reference(sha1);
if (!commit || parse_commit(commit)) {
+ html_status(404, "Not found", 0);
return;
}
match_path = ctx->qry.path;
fprintf(stderr, "[cgit] match_path=%s", match_path);
read_tree_recursive(commit->tree, NULL, 0, 0, paths, walk_tree, NULL);
if (!match)
return;
}
match_path = ctx->qry.path;
fprintf(stderr, "[cgit] match_path=%s", match_path);
read_tree_recursive(commit->tree, NULL, 0, 0, paths, walk_tree, NULL);
if (!match)
+ html_status(404, "Not found", 0);