diff options
Diffstat (limited to 'http-backend.c')
-rw-r--r-- | http-backend.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/http-backend.c b/http-backend.c index 6b85ffac27..80790bbaef 100644 --- a/http-backend.c +++ b/http-backend.c @@ -221,17 +221,19 @@ static void get_idx_file(char *name) static int http_config(const char *var, const char *value, void *cb) { + const char *p; + if (!strcmp(var, "http.getanyfile")) { getanyfile = git_config_bool(var, value); return 0; } - if (!prefixcmp(var, "http.")) { + if (skip_prefix(var, "http.", &p)) { int i; for (i = 0; i < ARRAY_SIZE(rpc_service); i++) { struct rpc_service *svc = &rpc_service[i]; - if (!strcmp(var + 5, svc->config_name)) { + if (!strcmp(p, svc->config_name)) { svc->enabled = git_config_bool(var, value); return 0; } @@ -244,15 +246,16 @@ static int http_config(const char *var, const char *value, void *cb) static struct rpc_service *select_service(const char *name) { + const char *svc_name; struct rpc_service *svc = NULL; int i; - if (prefixcmp(name, "git-")) + if (!skip_prefix(name, "git-", &svc_name)) forbidden("Unsupported service: '%s'", name); for (i = 0; i < ARRAY_SIZE(rpc_service); i++) { struct rpc_service *s = &rpc_service[i]; - if (!strcmp(s->name, name + 4)) { + if (!strcmp(s->name, svc_name)) { svc = s; break; } @@ -410,14 +413,14 @@ static void get_info_refs(char *arg) strbuf_release(&buf); } -static int show_head_ref(const char *name, const unsigned char *sha1, +static int show_head_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { struct strbuf *buf = cb_data; if (flag & REF_ISSYMREF) { - unsigned char sha1[20]; - const char *target = resolve_ref_unsafe(name, sha1, 1, NULL); + unsigned char unused[20]; + const char *target = resolve_ref_unsafe(refname, unused, 1, NULL); const char *target_nons = strip_namespace(target); strbuf_addf(buf, "ref: %s\n", target_nons); @@ -594,9 +597,11 @@ int main(int argc, char **argv) if (strcmp(method, c->method)) { const char *proto = getenv("SERVER_PROTOCOL"); - if (proto && !strcmp(proto, "HTTP/1.1")) + if (proto && !strcmp(proto, "HTTP/1.1")) { http_status(405, "Method Not Allowed"); - else + hdr_str("Allow", !strcmp(c->method, "GET") ? + "GET, HEAD" : c->method); + } else http_status(400, "Bad Request"); hdr_nocache(); end_headers(); @@ -605,9 +610,7 @@ int main(int argc, char **argv) cmd = c; n = out[0].rm_eo - out[0].rm_so; - cmd_arg = xmalloc(n); - memcpy(cmd_arg, dir + out[0].rm_so + 1, n-1); - cmd_arg[n-1] = '\0'; + cmd_arg = xmemdupz(dir + out[0].rm_so + 1, n - 1); dir[out[0].rm_so] = 0; break; } |