]> gitweb.ps.run Git - ps-cgit/blobdiff - cgit.c
Merge branch 'ml/head-include'
[ps-cgit] / cgit.c
diff --git a/cgit.c b/cgit.c
index 2afc5988afa1261b3adacfd4d8c307838766c1cb..513ea125bb196a065a4b1cc24f24cae0f571de52 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -208,6 +208,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 {
@@ -287,6 +288,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);
@@ -431,6 +434,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;
@@ -477,6 +481,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,