summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasaya Suzuki <masayasuzuki@google.com>2019-01-10 19:33:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-10 23:00:56 (GMT)
commitb79bdd8c1208103f106e9cf7a535b625521b21c9 (patch)
tree14e26ba4f1d67967ece2d7f30879cc9c70098cae
parentcf2fb92b00df0594aac2176b524db45b62795a38 (diff)
downloadgit-b79bdd8c1208103f106e9cf7a535b625521b21c9.zip
git-b79bdd8c1208103f106e9cf7a535b625521b21c9.tar.gz
git-b79bdd8c1208103f106e9cf7a535b625521b21c9.tar.bz2
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>
-rw-r--r--remote-curl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/remote-curl.c b/remote-curl.c
index d4673b6..91b39ca 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -547,6 +547,7 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
struct rpc_in_data {
struct rpc_state *rpc;
+ struct active_request_slot *slot;
};
/*
@@ -558,6 +559,13 @@ static size_t rpc_in(char *ptr, size_t eltsize,
{
size_t size = eltsize * nmemb;
struct rpc_in_data *data = buffer_;
+ long response_code;
+
+ if (curl_easy_getinfo(data->slot->curl, CURLINFO_RESPONSE_CODE,
+ &response_code) != CURLE_OK)
+ return size;
+ if (response_code >= 300)
+ return size;
if (size)
data->rpc->any_written = 1;
write_or_die(data->rpc->in, ptr, size);
@@ -774,7 +782,9 @@ retry:
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
rpc_in_data.rpc = rpc;
+ rpc_in_data.slot = slot;
curl_easy_setopt(slot->curl, CURLOPT_FILE, &rpc_in_data);
+ curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0);
rpc->any_written = 0;