| -rw-r--r-- | cgit.c | 6 | ||||
| -rw-r--r-- | cgit.h | 3 | ||||
| -rw-r--r-- | ui-atom.c | 6 | ||||
| -rw-r--r-- | ui-blob.c | 8 | ||||
| -rw-r--r-- | ui-plain.c | 6 | ||||
| -rw-r--r-- | ui-shared.c | 22 | ||||
| -rw-r--r-- | ui-shared.h | 1 |
7 files changed, 5 insertions, 47 deletions
@@ -208,7 +208,6 @@ 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 { @@ -288,8 +287,6 @@ 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); @@ -434,7 +431,6 @@ 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; @@ -481,8 +477,6 @@ 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, @@ -181,10 +181,7 @@ struct cgit_page { char *mimetype; char *charset; char *filename; - char *etag; char *title; - int status; - char *statusmsg; }; struct cgit_context { @@ -52,8 +52,7 @@ void add_entry(struct commit *commit, char *host) cgit_print_date(info->author_date, FMT_ATOMDATE, ctx.cfg.local_time); html("</published>\n"); if (host) { - html("<link rel='alternate' type='text/html' href='"); - html(cgit_httpscheme()); + html("<link rel='alternate' type='text/html' href='http://"); html_attr(host); html_attr(cgit_pageurl(ctx.repo->url, "commit", NULL)); if (ctx.cfg.virtual_root) @@ -114,8 +113,7 @@ void cgit_print_atom(char *tip, char *path, int max_count) html_txt(ctx.repo->desc); html("</subtitle>\n"); if (host) { - html("<link rel='alternate' type='text/html' href='"); - html(cgit_httpscheme()); + html("<link rel='alternate' type='text/html' href='http://"); html_attr(host); html_attr(cgit_repourl(ctx.repo->url)); html("'/>\n"); @@ -27,7 +27,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head) unsigned char sha1[20]; enum object_type type; - char *buf; + unsigned char *buf; unsigned long size; struct commit *commit; const char *paths[] = {path, NULL}; @@ -67,12 +67,6 @@ void cgit_print_blob(const char *hex, char *path, const char *head) buf[size] = '\0'; ctx.page.mimetype = ctx.qry.mimetype; - if (!ctx.page.mimetype) { - if (buffer_is_binary(buf, size)) - ctx.page.mimetype = "application/octet-stream"; - else - ctx.page.mimetype = "text/plain"; - } ctx.page.filename = path; cgit_print_http_headers(&ctx); write(htmlfd, buf, size); @@ -31,13 +31,9 @@ static void print_object(const unsigned char *sha1, const char *path) html_status(404, "Not found", 0); return; } - if (buffer_is_binary(buf, size)) - ctx.page.mimetype = "application/octet-stream"; - else - ctx.page.mimetype = "text/plain"; + ctx.page.mimetype = "text/plain"; ctx.page.filename = fmt("%s", path); ctx.page.size = size; - ctx.page.etag = sha1_to_hex(sha1); cgit_print_http_headers(&ctx); html_raw(buf, size); match = 1; diff --git a/ui-shared.c b/ui-shared.c index 66d5b82..fea2c40 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -34,17 +34,6 @@ void cgit_print_error(char *msg) html("</div>\n"); } -char *cgit_httpscheme() -{ - char *https; - - https = getenv("HTTPS"); - if (https != NULL && strcmp(https, "on") == 0) - return "https://"; - else - return "http://"; -} - char *cgit_hosturl() { char *host, *port; @@ -467,10 +456,6 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) void cgit_print_http_headers(struct cgit_context *ctx) { - const char *method = getenv("REQUEST_METHOD"); - - if (ctx->page.status) - htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); if (ctx->page.mimetype && ctx->page.charset) htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, ctx->page.charset); @@ -483,11 +468,7 @@ void cgit_print_http_headers(struct cgit_context *ctx) ctx->page.filename); htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); htmlf("Expires: %s\n", http_date(ctx->page.expires)); - if (ctx->page.etag) - htmlf("ETag: \"%s\"\n", ctx->page.etag); html("\n"); - if (method && !strcmp(method, "HEAD")) - exit(0); } void cgit_print_docstart(struct cgit_context *ctx) @@ -511,8 +492,7 @@ void cgit_print_docstart(struct cgit_context *ctx) html("'/>\n"); } if (host && ctx->repo) { - html("<link rel='alternate' title='Atom feed' href='"); - html(cgit_httpscheme()); + html("<link rel='alternate' title='Atom feed' href='http://"); html_attr(cgit_hosturl()); html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, fmt("h=%s", ctx->qry.head))); diff --git a/ui-shared.h b/ui-shared.h index bff4826..5a3821f 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -1,7 +1,6 @@ #ifndef UI_SHARED_H #define UI_SHARED_H -extern char *cgit_httpscheme(); extern char *cgit_hosturl(); extern char *cgit_repourl(const char *reponame); extern char *cgit_fileurl(const char *reponame, const char *pagename, |