]> gitweb.ps.run Git - ps-cgit/blobdiff - cgit.c
Merge branch 'lh/embedded'
[ps-cgit] / cgit.c
diff --git a/cgit.c b/cgit.c
index 38f0fdda6c3d76bca1fe7dd0734253b1f9ac4529..2039ab1de53699b6d29a23f1409461386589a227 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -31,6 +31,8 @@ void config_cb(const char *name, const char *value)
                ctx.cfg.favicon = xstrdup(value);
        else if (!strcmp(name, "footer"))
                ctx.cfg.footer = xstrdup(value);
+       else if (!strcmp(name, "head-include"))
+               ctx.cfg.head_include = xstrdup(value);
        else if (!strcmp(name, "header"))
                ctx.cfg.header = xstrdup(value);
        else if (!strcmp(name, "logo"))
@@ -210,6 +212,7 @@ static void prepare_context(struct cgit_context *ctx)
        ctx->page.size = 0;
        ctx->page.modified = time(NULL);
        ctx->page.expires = ctx->page.modified;
+       ctx->page.etag = NULL;
 }
 
 struct refmatch {
@@ -289,6 +292,8 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
        if (get_sha1(ctx->qry.head, sha1)) {
                tmp = xstrdup(ctx->qry.head);
                ctx->qry.head = ctx->repo->defbranch;
+               ctx->page.status = 404;
+               ctx->page.statusmsg = "not found";
                cgit_print_http_headers(ctx);
                cgit_print_docstart(ctx);
                cgit_print_pageheader(ctx);
@@ -433,6 +438,7 @@ static int calc_ttl()
 int main(int argc, const char **argv)
 {
        const char *cgit_config_env = getenv("CGIT_CONFIG");
+       const char *method = getenv("REQUEST_METHOD");
        const char *path;
        char *qry;
        int err, ttl;
@@ -479,6 +485,8 @@ int main(int argc, const char **argv)
 
        ttl = calc_ttl();
        ctx.page.expires += ttl*60;
+       if (method && !strcmp(method, "HEAD"))
+               ctx.cfg.nocache = 1;
        if (ctx.cfg.nocache)
                ctx.cfg.cache_size = 0;
        err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root,