]> Pileus Git - ~andy/git/commitdiff
http: return curl's AUTHAVAIL via slot_results
authorJeff King <peff@peff.net>
Thu, 31 Oct 2013 06:35:31 +0000 (02:35 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 31 Oct 2013 17:05:55 +0000 (10:05 -0700)
Callers of the http code may want to know which auth types
were available for the previous request. But after finishing
with the curl slot, they are not supposed to look at the
curl handle again. We already handle returning other
information via the slot_results struct; let's add a flag to
check the available auth.

Note that older versions of curl did not support this, so we
simply return 0 (something like "-1" would be worse, as the
value is a bitflag and we might accidentally set a flag).
This is sufficient for the callers planned in this series,
who only trigger some optional behavior if particular bits
are set, and can live with a fake "no bits" answer.

Signed-off-by: Jeff King <peff@peff.net>
http.c
http.h

diff --git a/http.c b/http.c
index 2d086aedfac9a8ea384c53f3b1963149b880ed31..1ea62fad4fa95c004f77ad4f09bab2a00cfab524 100644 (file)
--- a/http.c
+++ b/http.c
@@ -706,6 +706,12 @@ void finish_active_slot(struct active_request_slot *slot)
        if (slot->results != NULL) {
                slot->results->curl_result = slot->curl_result;
                slot->results->http_code = slot->http_code;
+#if LIBCURL_VERSION_NUM >= 0x070a08
+               curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL,
+                                 &slot->results->auth_avail);
+#else
+               slot->results->auth_avail = 0;
+#endif
        }
 
        /* Run callback if appropriate */
diff --git a/http.h b/http.h
index d77c1b54f24d142461b9e1a0d11cf6de041bc59f..81d48432930b3b68f8f420028ba69b1f91063080 100644 (file)
--- a/http.h
+++ b/http.h
@@ -54,6 +54,7 @@
 struct slot_results {
        CURLcode curl_result;
        long http_code;
+       long auth_avail;
 };
 
 struct active_request_slot {