remote-curl: unset CURLOPT_FAILONERROR

By not setting CURLOPT_FAILONERROR, curl parses the HTTP response headers even if the response is an error. This makes GIT_CURL_VERBOSE to show the HTTP headers, which is useful for debugging. Signed-off-by: Masaya Suzuki <masayasuzuki@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Masaya Suzuki committed Jan 10, 2019 at 11:33 UTC b79bdd8c1208103f106e9cf7a535b625521b21c9
1 file changed +10
remote-curl.c
+10
@@ -547,6 +547,7 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
547
548 struct rpc_in_data {
549 struct rpc_state *rpc;
550 + struct active_request_slot *slot;
551 };
552
553 /*
@@ -558,6 +559,13 @@ static size_t rpc_in(char *ptr, size_t eltsize,
559 {
560 size_t size = eltsize * nmemb;
561 struct rpc_in_data *data = buffer_;
562 + long response_code;
563 +
564 + if (curl_easy_getinfo(data->slot->curl, CURLINFO_RESPONSE_CODE,
565 + &response_code) != CURLE_OK)
566 + return size;
567 + if (response_code >= 300)
568 + return size;
569 if (size)
570 data->rpc->any_written = 1;
571 write_or_die(data->rpc->in, ptr, size);
@@ -774,7 +782,9 @@ retry:
782 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
783 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
784 rpc_in_data.rpc = rpc;
785 + rpc_in_data.slot = slot;
786 curl_easy_setopt(slot->curl, CURLOPT_FILE, &rpc_in_data);
787 + curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);
788
789
790 rpc->any_written = 0;