remote-curl: fix large pushes with GSSAPI

Due to an interaction between the way libcurl handles GSSAPI authentication over HTTP and the way git uses libcurl, large pushes (those over http.postBuffer bytes) would fail due to an authentication failure requiring a rewind of the curl buffer. Such a rewind was not possible because the data did not fit into the entire buffer. Enable the use of the Expect: 100-continue header for large requests where the server offers GSSAPI authentication to avoid this issue, since the request would otherwise fail. This allows git to get the authentication data right before sending the pack contents. Existing cases where pushes would succeed, including small requests using GSSAPI, still disable the use of 100 Continue, as it causes problems for some remote HTTP implementations (servers and proxies). Signed-off-by: Brian M. Carlson <sandals@crustytoothpaste.net> Signed-off-by: Jeff King <peff@peff.net>

Brian M. Carlson committed Oct 31, 2013 at 02:36 UTC c80d96ca0c3cf948c5062bf6591a46c625620b6d
1 file changed +9 -2
remote-curl.c
+9 -2
@@ -423,6 +423,7 @@ static int post_rpc(struct rpc_state *rpc)
423 char *gzip_body = NULL;
424 size_t gzip_size = 0;
425 int err, large_request = 0;
426 + int needs_100_continue = 0;
427
428 /* Try to load the entire request, if we can fit it into the
429 * allocated buffer space we can use HTTP/1.0 and avoid the
@@ -446,16 +447,22 @@ static int post_rpc(struct rpc_state *rpc)
447 }
448
449 if (large_request) {
450 + struct slot_results results;
451 +
452 do {
450 - err = probe_rpc(rpc, NULL);
453 + err = probe_rpc(rpc, &results);
454 } while (err == HTTP_REAUTH);
455 if (err != HTTP_OK)
456 return -1;
457 +
458 + if (results.auth_avail & CURLAUTH_GSSNEGOTIATE)
459 + needs_100_continue = 1;
460 }
461
462 headers = curl_slist_append(headers, rpc->hdr_content_type);
463 headers = curl_slist_append(headers, rpc->hdr_accept);
458 - headers = curl_slist_append(headers, "Expect:");
464 + headers = curl_slist_append(headers, needs_100_continue ?
465 + "Expect: 100-continue" : "Expect:");
466
467 retry:
468 slot = get_active_slot();