setup.h: move declarations for setup.c functions from cache.h
[git.git] / http-backend.c
blob042ccf12e8ccfbb4e05e07cf7efa61a5f1a4dc80
1 #include "cache.h"
2 #include "alloc.h"
3 #include "config.h"
4 #include "environment.h"
5 #include "hex.h"
6 #include "repository.h"
7 #include "refs.h"
8 #include "pkt-line.h"
9 #include "object.h"
10 #include "tag.h"
11 #include "exec-cmd.h"
12 #include "run-command.h"
13 #include "string-list.h"
14 #include "url.h"
15 #include "strvec.h"
16 #include "packfile.h"
17 #include "object-store.h"
18 #include "protocol.h"
19 #include "date.h"
20 #include "wrapper.h"
22 static const char content_type[] = "Content-Type";
23 static const char content_length[] = "Content-Length";
24 static const char last_modified[] = "Last-Modified";
25 static int getanyfile = 1;
26 static unsigned long max_request_buffer = 10 * 1024 * 1024;
28 static struct string_list *query_params;
30 struct rpc_service {
31 const char *name;
32 const char *config_name;
33 unsigned buffer_input : 1;
34 signed enabled : 2;
37 static struct rpc_service rpc_service[] = {
38 { "upload-pack", "uploadpack", 1, 1 },
39 { "receive-pack", "receivepack", 0, -1 },
42 static struct string_list *get_parameters(void)
44 if (!query_params) {
45 const char *query = getenv("QUERY_STRING");
47 CALLOC_ARRAY(query_params, 1);
48 while (query && *query) {
49 char *name = url_decode_parameter_name(&query);
50 char *value = url_decode_parameter_value(&query);
51 struct string_list_item *i;
53 i = string_list_lookup(query_params, name);
54 if (!i)
55 i = string_list_insert(query_params, name);
56 else
57 free(i->util);
58 i->util = value;
61 return query_params;
64 static const char *get_parameter(const char *name)
66 struct string_list_item *i;
67 i = string_list_lookup(get_parameters(), name);
68 return i ? i->util : NULL;
71 __attribute__((format (printf, 2, 3)))
72 static void format_write(int fd, const char *fmt, ...)
74 static char buffer[1024];
76 va_list args;
77 unsigned n;
79 va_start(args, fmt);
80 n = vsnprintf(buffer, sizeof(buffer), fmt, args);
81 va_end(args);
82 if (n >= sizeof(buffer))
83 die("protocol error: impossibly long line");
85 write_or_die(fd, buffer, n);
88 static void http_status(struct strbuf *hdr, unsigned code, const char *msg)
90 strbuf_addf(hdr, "Status: %u %s\r\n", code, msg);
93 static void hdr_str(struct strbuf *hdr, const char *name, const char *value)
95 strbuf_addf(hdr, "%s: %s\r\n", name, value);
98 static void hdr_int(struct strbuf *hdr, const char *name, uintmax_t value)
100 strbuf_addf(hdr, "%s: %" PRIuMAX "\r\n", name, value);
103 static void hdr_date(struct strbuf *hdr, const char *name, timestamp_t when)
105 const char *value = show_date(when, 0, DATE_MODE(RFC2822));
106 hdr_str(hdr, name, value);
109 static void hdr_nocache(struct strbuf *hdr)
111 hdr_str(hdr, "Expires", "Fri, 01 Jan 1980 00:00:00 GMT");
112 hdr_str(hdr, "Pragma", "no-cache");
113 hdr_str(hdr, "Cache-Control", "no-cache, max-age=0, must-revalidate");
116 static void hdr_cache_forever(struct strbuf *hdr)
118 timestamp_t now = time(NULL);
119 hdr_date(hdr, "Date", now);
120 hdr_date(hdr, "Expires", now + 31536000);
121 hdr_str(hdr, "Cache-Control", "public, max-age=31536000");
124 static void end_headers(struct strbuf *hdr)
126 strbuf_add(hdr, "\r\n", 2);
127 write_or_die(1, hdr->buf, hdr->len);
128 strbuf_release(hdr);
131 __attribute__((format (printf, 2, 3)))
132 static NORETURN void not_found(struct strbuf *hdr, const char *err, ...)
134 va_list params;
136 http_status(hdr, 404, "Not Found");
137 hdr_nocache(hdr);
138 end_headers(hdr);
140 va_start(params, err);
141 if (err && *err)
142 vfprintf(stderr, err, params);
143 va_end(params);
144 exit(0);
147 __attribute__((format (printf, 2, 3)))
148 static NORETURN void forbidden(struct strbuf *hdr, const char *err, ...)
150 va_list params;
152 http_status(hdr, 403, "Forbidden");
153 hdr_nocache(hdr);
154 end_headers(hdr);
156 va_start(params, err);
157 if (err && *err)
158 vfprintf(stderr, err, params);
159 va_end(params);
160 exit(0);
163 static void select_getanyfile(struct strbuf *hdr)
165 if (!getanyfile)
166 forbidden(hdr, "Unsupported service: getanyfile");
169 static void send_strbuf(struct strbuf *hdr,
170 const char *type, struct strbuf *buf)
172 hdr_int(hdr, content_length, buf->len);
173 hdr_str(hdr, content_type, type);
174 end_headers(hdr);
175 write_or_die(1, buf->buf, buf->len);
178 static void send_local_file(struct strbuf *hdr, const char *the_type,
179 const char *name)
181 char *p = git_pathdup("%s", name);
182 size_t buf_alloc = 8192;
183 char *buf = xmalloc(buf_alloc);
184 int fd;
185 struct stat sb;
187 fd = open(p, O_RDONLY);
188 if (fd < 0)
189 not_found(hdr, "Cannot open '%s': %s", p, strerror(errno));
190 if (fstat(fd, &sb) < 0)
191 die_errno("Cannot stat '%s'", p);
193 hdr_int(hdr, content_length, sb.st_size);
194 hdr_str(hdr, content_type, the_type);
195 hdr_date(hdr, last_modified, sb.st_mtime);
196 end_headers(hdr);
198 for (;;) {
199 ssize_t n = xread(fd, buf, buf_alloc);
200 if (n < 0)
201 die_errno("Cannot read '%s'", p);
202 if (!n)
203 break;
204 write_or_die(1, buf, n);
206 close(fd);
207 free(buf);
208 free(p);
211 static void get_text_file(struct strbuf *hdr, char *name)
213 select_getanyfile(hdr);
214 hdr_nocache(hdr);
215 send_local_file(hdr, "text/plain", name);
218 static void get_loose_object(struct strbuf *hdr, char *name)
220 select_getanyfile(hdr);
221 hdr_cache_forever(hdr);
222 send_local_file(hdr, "application/x-git-loose-object", name);
225 static void get_pack_file(struct strbuf *hdr, char *name)
227 select_getanyfile(hdr);
228 hdr_cache_forever(hdr);
229 send_local_file(hdr, "application/x-git-packed-objects", name);
232 static void get_idx_file(struct strbuf *hdr, char *name)
234 select_getanyfile(hdr);
235 hdr_cache_forever(hdr);
236 send_local_file(hdr, "application/x-git-packed-objects-toc", name);
239 static void http_config(void)
241 int i, value = 0;
242 struct strbuf var = STRBUF_INIT;
244 git_config_get_bool("http.getanyfile", &getanyfile);
245 git_config_get_ulong("http.maxrequestbuffer", &max_request_buffer);
247 for (i = 0; i < ARRAY_SIZE(rpc_service); i++) {
248 struct rpc_service *svc = &rpc_service[i];
249 strbuf_addf(&var, "http.%s", svc->config_name);
250 if (!git_config_get_bool(var.buf, &value))
251 svc->enabled = value;
252 strbuf_reset(&var);
255 strbuf_release(&var);
258 static struct rpc_service *select_service(struct strbuf *hdr, const char *name)
260 const char *svc_name;
261 struct rpc_service *svc = NULL;
262 int i;
264 if (!skip_prefix(name, "git-", &svc_name))
265 forbidden(hdr, "Unsupported service: '%s'", name);
267 for (i = 0; i < ARRAY_SIZE(rpc_service); i++) {
268 struct rpc_service *s = &rpc_service[i];
269 if (!strcmp(s->name, svc_name)) {
270 svc = s;
271 break;
275 if (!svc)
276 forbidden(hdr, "Unsupported service: '%s'", name);
278 if (svc->enabled < 0) {
279 const char *user = getenv("REMOTE_USER");
280 svc->enabled = (user && *user) ? 1 : 0;
282 if (!svc->enabled)
283 forbidden(hdr, "Service not enabled: '%s'", svc->name);
284 return svc;
287 static void write_to_child(int out, const unsigned char *buf, ssize_t len, const char *prog_name)
289 if (write_in_full(out, buf, len) < 0)
290 die("unable to write to '%s'", prog_name);
294 * This is basically strbuf_read(), except that if we
295 * hit max_request_buffer we die (we'd rather reject a
296 * maliciously large request than chew up infinite memory).
298 static ssize_t read_request_eof(int fd, unsigned char **out)
300 size_t len = 0, alloc = 8192;
301 unsigned char *buf = xmalloc(alloc);
303 if (max_request_buffer < alloc)
304 max_request_buffer = alloc;
306 while (1) {
307 ssize_t cnt;
309 cnt = read_in_full(fd, buf + len, alloc - len);
310 if (cnt < 0) {
311 free(buf);
312 return -1;
315 /* partial read from read_in_full means we hit EOF */
316 len += cnt;
317 if (len < alloc) {
318 *out = buf;
319 return len;
322 /* otherwise, grow and try again (if we can) */
323 if (alloc == max_request_buffer)
324 die("request was larger than our maximum size (%lu);"
325 " try setting GIT_HTTP_MAX_REQUEST_BUFFER",
326 max_request_buffer);
328 alloc = alloc_nr(alloc);
329 if (alloc > max_request_buffer)
330 alloc = max_request_buffer;
331 REALLOC_ARRAY(buf, alloc);
335 static ssize_t read_request_fixed_len(int fd, ssize_t req_len, unsigned char **out)
337 unsigned char *buf = NULL;
338 ssize_t cnt = 0;
340 if (max_request_buffer < req_len) {
341 die("request was larger than our maximum size (%lu): "
342 "%" PRIuMAX "; try setting GIT_HTTP_MAX_REQUEST_BUFFER",
343 max_request_buffer, (uintmax_t)req_len);
346 buf = xmalloc(req_len);
347 cnt = read_in_full(fd, buf, req_len);
348 if (cnt < 0) {
349 free(buf);
350 return -1;
352 *out = buf;
353 return cnt;
356 static ssize_t get_content_length(void)
358 ssize_t val = -1;
359 const char *str = getenv("CONTENT_LENGTH");
361 if (str && *str && !git_parse_ssize_t(str, &val))
362 die("failed to parse CONTENT_LENGTH: %s", str);
363 return val;
366 static ssize_t read_request(int fd, unsigned char **out, ssize_t req_len)
368 if (req_len < 0)
369 return read_request_eof(fd, out);
370 else
371 return read_request_fixed_len(fd, req_len, out);
374 static void inflate_request(const char *prog_name, int out, int buffer_input, ssize_t req_len)
376 git_zstream stream;
377 unsigned char *full_request = NULL;
378 unsigned char in_buf[8192];
379 unsigned char out_buf[8192];
380 unsigned long cnt = 0;
381 int req_len_defined = req_len >= 0;
382 size_t req_remaining_len = req_len;
384 memset(&stream, 0, sizeof(stream));
385 git_inflate_init_gzip_only(&stream);
387 while (1) {
388 ssize_t n;
390 if (buffer_input) {
391 if (full_request)
392 n = 0; /* nothing left to read */
393 else
394 n = read_request(0, &full_request, req_len);
395 stream.next_in = full_request;
396 } else {
397 ssize_t buffer_len;
398 if (req_len_defined && req_remaining_len <= sizeof(in_buf))
399 buffer_len = req_remaining_len;
400 else
401 buffer_len = sizeof(in_buf);
402 n = xread(0, in_buf, buffer_len);
403 stream.next_in = in_buf;
404 if (req_len_defined && n > 0)
405 req_remaining_len -= n;
408 if (n <= 0)
409 die("request ended in the middle of the gzip stream");
410 stream.avail_in = n;
412 while (0 < stream.avail_in) {
413 int ret;
415 stream.next_out = out_buf;
416 stream.avail_out = sizeof(out_buf);
418 ret = git_inflate(&stream, Z_NO_FLUSH);
419 if (ret != Z_OK && ret != Z_STREAM_END)
420 die("zlib error inflating request, result %d", ret);
422 n = stream.total_out - cnt;
423 write_to_child(out, out_buf, stream.total_out - cnt, prog_name);
424 cnt = stream.total_out;
426 if (ret == Z_STREAM_END)
427 goto done;
431 done:
432 git_inflate_end(&stream);
433 close(out);
434 free(full_request);
437 static void copy_request(const char *prog_name, int out, ssize_t req_len)
439 unsigned char *buf;
440 ssize_t n = read_request(0, &buf, req_len);
441 if (n < 0)
442 die_errno("error reading request body");
443 write_to_child(out, buf, n, prog_name);
444 close(out);
445 free(buf);
448 static void pipe_fixed_length(const char *prog_name, int out, size_t req_len)
450 unsigned char buf[8192];
451 size_t remaining_len = req_len;
453 while (remaining_len > 0) {
454 size_t chunk_length = remaining_len > sizeof(buf) ? sizeof(buf) : remaining_len;
455 ssize_t n = xread(0, buf, chunk_length);
456 if (n < 0)
457 die_errno("Reading request failed");
458 write_to_child(out, buf, n, prog_name);
459 remaining_len -= n;
462 close(out);
465 static void run_service(const char **argv, int buffer_input)
467 const char *encoding = getenv("HTTP_CONTENT_ENCODING");
468 const char *user = getenv("REMOTE_USER");
469 const char *host = getenv("REMOTE_ADDR");
470 int gzipped_request = 0;
471 struct child_process cld = CHILD_PROCESS_INIT;
472 ssize_t req_len = get_content_length();
474 if (encoding && (!strcmp(encoding, "gzip") || !strcmp(encoding, "x-gzip")))
475 gzipped_request = 1;
477 if (!user || !*user)
478 user = "anonymous";
479 if (!host || !*host)
480 host = "(none)";
482 if (!getenv("GIT_COMMITTER_NAME"))
483 strvec_pushf(&cld.env, "GIT_COMMITTER_NAME=%s", user);
484 if (!getenv("GIT_COMMITTER_EMAIL"))
485 strvec_pushf(&cld.env,
486 "GIT_COMMITTER_EMAIL=%s@http.%s", user, host);
488 strvec_pushv(&cld.args, argv);
489 if (buffer_input || gzipped_request || req_len >= 0)
490 cld.in = -1;
491 cld.git_cmd = 1;
492 cld.clean_on_exit = 1;
493 cld.wait_after_clean = 1;
494 if (start_command(&cld))
495 exit(1);
497 close(1);
498 if (gzipped_request)
499 inflate_request(argv[0], cld.in, buffer_input, req_len);
500 else if (buffer_input)
501 copy_request(argv[0], cld.in, req_len);
502 else if (req_len >= 0)
503 pipe_fixed_length(argv[0], cld.in, req_len);
504 else
505 close(0);
507 if (finish_command(&cld))
508 exit(1);
511 static int show_text_ref(const char *name, const struct object_id *oid,
512 int flag UNUSED, void *cb_data)
514 const char *name_nons = strip_namespace(name);
515 struct strbuf *buf = cb_data;
516 struct object *o = parse_object(the_repository, oid);
517 if (!o)
518 return 0;
520 strbuf_addf(buf, "%s\t%s\n", oid_to_hex(oid), name_nons);
521 if (o->type == OBJ_TAG) {
522 o = deref_tag(the_repository, o, name, 0);
523 if (!o)
524 return 0;
525 strbuf_addf(buf, "%s\t%s^{}\n", oid_to_hex(&o->oid),
526 name_nons);
528 return 0;
531 static void get_info_refs(struct strbuf *hdr, char *arg UNUSED)
533 const char *service_name = get_parameter("service");
534 struct strbuf buf = STRBUF_INIT;
536 hdr_nocache(hdr);
538 if (service_name) {
539 const char *argv[] = {NULL /* service name */,
540 "--http-backend-info-refs",
541 ".", NULL};
542 struct rpc_service *svc = select_service(hdr, service_name);
544 strbuf_addf(&buf, "application/x-git-%s-advertisement",
545 svc->name);
546 hdr_str(hdr, content_type, buf.buf);
547 end_headers(hdr);
550 if (determine_protocol_version_server() != protocol_v2) {
551 packet_write_fmt(1, "# service=git-%s\n", svc->name);
552 packet_flush(1);
555 argv[0] = svc->name;
556 run_service(argv, 0);
558 } else {
559 select_getanyfile(hdr);
560 for_each_namespaced_ref(show_text_ref, &buf);
561 send_strbuf(hdr, "text/plain", &buf);
563 strbuf_release(&buf);
566 static int show_head_ref(const char *refname, const struct object_id *oid,
567 int flag, void *cb_data)
569 struct strbuf *buf = cb_data;
571 if (flag & REF_ISSYMREF) {
572 const char *target = resolve_ref_unsafe(refname,
573 RESOLVE_REF_READING,
574 NULL, NULL);
576 if (target)
577 strbuf_addf(buf, "ref: %s\n", strip_namespace(target));
578 } else {
579 strbuf_addf(buf, "%s\n", oid_to_hex(oid));
582 return 0;
585 static void get_head(struct strbuf *hdr, char *arg UNUSED)
587 struct strbuf buf = STRBUF_INIT;
589 select_getanyfile(hdr);
590 head_ref_namespaced(show_head_ref, &buf);
591 send_strbuf(hdr, "text/plain", &buf);
592 strbuf_release(&buf);
595 static void get_info_packs(struct strbuf *hdr, char *arg UNUSED)
597 size_t objdirlen = strlen(get_object_directory());
598 struct strbuf buf = STRBUF_INIT;
599 struct packed_git *p;
600 size_t cnt = 0;
602 select_getanyfile(hdr);
603 for (p = get_all_packs(the_repository); p; p = p->next) {
604 if (p->pack_local)
605 cnt++;
608 strbuf_grow(&buf, cnt * 53 + 2);
609 for (p = get_all_packs(the_repository); p; p = p->next) {
610 if (p->pack_local)
611 strbuf_addf(&buf, "P %s\n", p->pack_name + objdirlen + 6);
613 strbuf_addch(&buf, '\n');
615 hdr_nocache(hdr);
616 send_strbuf(hdr, "text/plain; charset=utf-8", &buf);
617 strbuf_release(&buf);
620 static void check_content_type(struct strbuf *hdr, const char *accepted_type)
622 const char *actual_type = getenv("CONTENT_TYPE");
624 if (!actual_type)
625 actual_type = "";
627 if (strcmp(actual_type, accepted_type)) {
628 http_status(hdr, 415, "Unsupported Media Type");
629 hdr_nocache(hdr);
630 end_headers(hdr);
631 format_write(1,
632 "Expected POST with Content-Type '%s',"
633 " but received '%s' instead.\n",
634 accepted_type, actual_type);
635 exit(0);
639 static void service_rpc(struct strbuf *hdr, char *service_name)
641 const char *argv[] = {NULL, "--stateless-rpc", ".", NULL};
642 struct rpc_service *svc = select_service(hdr, service_name);
643 struct strbuf buf = STRBUF_INIT;
645 strbuf_reset(&buf);
646 strbuf_addf(&buf, "application/x-git-%s-request", svc->name);
647 check_content_type(hdr, buf.buf);
649 hdr_nocache(hdr);
651 strbuf_reset(&buf);
652 strbuf_addf(&buf, "application/x-git-%s-result", svc->name);
653 hdr_str(hdr, content_type, buf.buf);
655 end_headers(hdr);
657 argv[0] = svc->name;
658 run_service(argv, svc->buffer_input);
659 strbuf_release(&buf);
662 static int dead;
663 static NORETURN void die_webcgi(const char *err, va_list params)
665 if (dead <= 1) {
666 struct strbuf hdr = STRBUF_INIT;
667 report_fn die_message_fn = get_die_message_routine();
669 die_message_fn(err, params);
671 http_status(&hdr, 500, "Internal Server Error");
672 hdr_nocache(&hdr);
673 end_headers(&hdr);
675 exit(0); /* we successfully reported a failure ;-) */
678 static int die_webcgi_recursing(void)
680 return dead++ > 1;
683 static char* getdir(void)
685 struct strbuf buf = STRBUF_INIT;
686 char *pathinfo = getenv("PATH_INFO");
687 char *root = getenv("GIT_PROJECT_ROOT");
688 char *path = getenv("PATH_TRANSLATED");
690 if (root && *root) {
691 if (!pathinfo || !*pathinfo)
692 die("GIT_PROJECT_ROOT is set but PATH_INFO is not");
693 if (daemon_avoid_alias(pathinfo))
694 die("'%s': aliased", pathinfo);
695 end_url_with_slash(&buf, root);
696 if (pathinfo[0] == '/')
697 pathinfo++;
698 strbuf_addstr(&buf, pathinfo);
699 return strbuf_detach(&buf, NULL);
700 } else if (path && *path) {
701 return xstrdup(path);
702 } else
703 die("No GIT_PROJECT_ROOT or PATH_TRANSLATED from server");
704 return NULL;
707 static struct service_cmd {
708 const char *method;
709 const char *pattern;
710 void (*imp)(struct strbuf *, char *);
711 } services[] = {
712 {"GET", "/HEAD$", get_head},
713 {"GET", "/info/refs$", get_info_refs},
714 {"GET", "/objects/info/alternates$", get_text_file},
715 {"GET", "/objects/info/http-alternates$", get_text_file},
716 {"GET", "/objects/info/packs$", get_info_packs},
717 {"GET", "/objects/[0-9a-f]{2}/[0-9a-f]{38}$", get_loose_object},
718 {"GET", "/objects/[0-9a-f]{2}/[0-9a-f]{62}$", get_loose_object},
719 {"GET", "/objects/pack/pack-[0-9a-f]{40}\\.pack$", get_pack_file},
720 {"GET", "/objects/pack/pack-[0-9a-f]{64}\\.pack$", get_pack_file},
721 {"GET", "/objects/pack/pack-[0-9a-f]{40}\\.idx$", get_idx_file},
722 {"GET", "/objects/pack/pack-[0-9a-f]{64}\\.idx$", get_idx_file},
724 {"POST", "/git-upload-pack$", service_rpc},
725 {"POST", "/git-receive-pack$", service_rpc}
728 static int bad_request(struct strbuf *hdr, const struct service_cmd *c)
730 const char *proto = getenv("SERVER_PROTOCOL");
732 if (proto && !strcmp(proto, "HTTP/1.1")) {
733 http_status(hdr, 405, "Method Not Allowed");
734 hdr_str(hdr, "Allow",
735 !strcmp(c->method, "GET") ? "GET, HEAD" : c->method);
736 } else
737 http_status(hdr, 400, "Bad Request");
738 hdr_nocache(hdr);
739 end_headers(hdr);
740 return 0;
743 int cmd_main(int argc UNUSED, const char **argv UNUSED)
745 char *method = getenv("REQUEST_METHOD");
746 const char *proto_header;
747 char *dir;
748 struct service_cmd *cmd = NULL;
749 char *cmd_arg = NULL;
750 int i;
751 struct strbuf hdr = STRBUF_INIT;
753 set_die_routine(die_webcgi);
754 set_die_is_recursing_routine(die_webcgi_recursing);
756 if (!method)
757 die("No REQUEST_METHOD from server");
758 if (!strcmp(method, "HEAD"))
759 method = "GET";
760 dir = getdir();
762 for (i = 0; i < ARRAY_SIZE(services); i++) {
763 struct service_cmd *c = &services[i];
764 regex_t re;
765 regmatch_t out[1];
766 int ret;
768 if (regcomp(&re, c->pattern, REG_EXTENDED))
769 die("Bogus regex in service table: %s", c->pattern);
770 ret = regexec(&re, dir, 1, out, 0);
771 regfree(&re);
773 if (!ret) {
774 size_t n;
776 if (strcmp(method, c->method))
777 return bad_request(&hdr, c);
779 cmd = c;
780 n = out[0].rm_eo - out[0].rm_so;
781 cmd_arg = xmemdupz(dir + out[0].rm_so + 1, n - 1);
782 dir[out[0].rm_so] = 0;
783 break;
787 if (!cmd)
788 not_found(&hdr, "Request not supported: '%s'", dir);
790 setup_path();
791 if (!enter_repo(dir, 0))
792 not_found(&hdr, "Not a git repository: '%s'", dir);
793 if (!getenv("GIT_HTTP_EXPORT_ALL") &&
794 access("git-daemon-export-ok", F_OK) )
795 not_found(&hdr, "Repository not exported: '%s'", dir);
796 free(dir);
798 http_config();
799 max_request_buffer = git_env_ulong("GIT_HTTP_MAX_REQUEST_BUFFER",
800 max_request_buffer);
801 proto_header = getenv("HTTP_GIT_PROTOCOL");
802 if (proto_header)
803 setenv(GIT_PROTOCOL_ENVIRONMENT, proto_header, 0);
805 cmd->imp(&hdr, cmd_arg);
806 free(cmd_arg);
807 return 0;