Merge branch 'ew/http-backend-batch-headers'
authorJunio C Hamano <gitster@pobox.com>
Fri, 12 Aug 2016 16:47:38 +0000 (09:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Aug 2016 16:47:38 +0000 (09:47 -0700)
The http-backend (the server-side component of smart-http
transport) used to trickle the HTTP header one at a time. Now
these write(2)s are batched.

* ew/http-backend-batch-headers:
http-backend: buffer headers before sending

1  2 
http-backend.c
diff --cc http-backend.c
index 0d59499a51d7f1eecf5b28254b624a991f0e1db4,52314039e383b46fff7f9b739fb6e002ddde97c2..adc8c8c3da6aaabe9f279b2a9841fc924ae39c1d
@@@ -632,14 -638,33 +638,30 @@@ static struct service_cmd 
        {"POST", "/git-receive-pack$", service_rpc}
  };
  
 -int main(int argc, char **argv)
+ static int bad_request(struct strbuf *hdr, const struct service_cmd *c)
+ {
+       const char *proto = getenv("SERVER_PROTOCOL");
+       if (proto && !strcmp(proto, "HTTP/1.1")) {
+               http_status(hdr, 405, "Method Not Allowed");
+               hdr_str(hdr, "Allow",
+                       !strcmp(c->method, "GET") ? "GET, HEAD" : c->method);
+       } else
+               http_status(hdr, 400, "Bad Request");
+       hdr_nocache(hdr);
+       end_headers(hdr);
+       return 0;
+ }
 +int cmd_main(int argc, const char **argv)
  {
        char *method = getenv("REQUEST_METHOD");
        char *dir;
        struct service_cmd *cmd = NULL;
        char *cmd_arg = NULL;
        int i;
+       struct strbuf hdr = STRBUF_INIT;
  
 -      git_setup_gettext();
 -
 -      git_extract_argv0_path(argv[0]);
        set_die_routine(die_webcgi);
        set_die_is_recursing_routine(die_webcgi_recursing);