# [PATCH] Allow any HTTP authentication scheme, not only basic

4 messages from 2009-03-31 to 2009-04-01. Participants: Martin Storsjo, Johannes Schindelin, Martin Storsjö.
Thread: https://gitlist.dev/t/18669

## Martin Storsjo, 2009-03-31 17:31

Subject: [PATCH] Allow any HTTP authentication scheme, not only basic
Message-ID: <1238520686-546-1-git-send-email-martin@martin.st>
URL: https://gitlist.dev/e/1238520686-546-1-git-send-email-martin%40martin.st

```
Signed-off-by: Martin Storsjo <martin@martin.st>
---
 http.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/http.c b/http.c
index 2fc55d6..7cb53e8 100644
--- a/http.c
+++ b/http.c
@@ -165,6 +165,7 @@ static CURL *get_curl_handle(void)
 #if LIBCURL_VERSION_NUM >= 0x070907
 	curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
 #endif
+	curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
 
 	init_curl_http_auth(result);
 
-- 
1.6.0.2

```

## Martin Storsjo, 2009-03-31 18:54

Subject: [PATCH] Allow any HTTP authentication scheme, not only basic
Message-ID: <1238525665-10776-1-git-send-email-martin@martin.st>
URL: https://gitlist.dev/e/1238525665-10776-1-git-send-email-martin%40martin.st
In-Reply-To: <1238520686-546-1-git-send-email-martin@martin.st>

```
Signed-off-by: Martin Storsjo <martin@martin.st>
---
Updated patch, enable only on libcurl versions new enough

 http.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/http.c b/http.c
index 2fc55d6..eae74aa 100644
--- a/http.c
+++ b/http.c
@@ -165,6 +165,9 @@ static CURL *get_curl_handle(void)
 #if LIBCURL_VERSION_NUM >= 0x070907
 	curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
 #endif
+#if LIBCURL_VERSION_NUM >= 0x070a06
+	curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
+#endif
 
 	init_curl_http_auth(result);
 
-- 
1.6.0.2

```

## Johannes Schindelin, 2009-03-31 19:04

Subject: Re: [PATCH] Allow any HTTP authentication scheme, not only basic
Message-ID: <alpine.DEB.1.00.0903312104010.6676@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0903312104010.6676%40intel-tinevez-2-302
In-Reply-To: <1238525665-10776-1-git-send-email-martin@martin.st>

```
Hi,

On Tue, 31 Mar 2009, Martin Storsjo wrote:

> Updated patch, enable only on libcurl versions new enough

Heh, you beat me to looking up from which version onward curl supports 
this...

Thanks!
Dscho

```

## Martin Storsjö, 2009-04-01 15:06

Subject: Re: [PATCH] Allow any HTTP authentication scheme, not only basic
Message-ID: <Pine.LNX.4.64.0904011750260.5901@localhost.localdomain>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0904011750260.5901%40localhost.localdomain
In-Reply-To: <alpine.DEB.1.00.0903312104010.6676@intel-tinevez-2-302>

```
Hi,

My patch doesn't seem to come completely without troubles, though.

I still find this a potentially valuable scenario; e.g. for a public repo 
with push access only over HTTP, but using secure digest authentication 
instead of sending the credentials in plaintext.

One downside is that it causes a lot more HTTP requests, since libcurl 
initially tries without any authentication for (almost?) every request, 
doubling the number of requests made.


Fetching works just fine, but pushing may fail on auth problems in some 
cases where it wouldn't fail otherwise, if only basic authentication was 
used and libcurl automatically used that without probing what 
authentication scheme the server uses.

Things generally seem to work fine with Apache, but with Lighttpd, 
retrying with proper credentials may fail due to CURLE_SEND_FAIL_REWIND /* 
65 - Sending the data requires a rewind that failed */. This issue can be 
fixed by another patch (that I'll send soon).

Even after fixing that, there still seems to be some issues on some older 
curl versions; in particular, 7.16.3, shipped in OS X Leopard, returns 
error code CURLE_HTTP_RETURNED_ERROR instead of retrying properly with 
authentication.

// Martin

```
