l10n: Update git.pot (1 new messages)
[gitweb.git] / http.c
diff --git a/http.c b/http.c
index 8ac8eb6c38e21bdb347f59ec41162270ebe82c04..2ec37891f36693b278b095b51331531a23d96d36 100644 (file)
--- a/http.c
+++ b/http.c
@@ -210,14 +210,23 @@ static int http_options(const char *var, const char *value, void *cb)
 
 static void init_curl_http_auth(CURL *result)
 {
-       if (http_auth.username) {
-               struct strbuf up = STRBUF_INIT;
-               credential_fill(&http_auth);
+       if (!http_auth.username)
+               return;
+
+       credential_fill(&http_auth);
+
+#if LIBCURL_VERSION_NUM >= 0x071301
+       curl_easy_setopt(result, CURLOPT_USERNAME, http_auth.username);
+       curl_easy_setopt(result, CURLOPT_PASSWORD, http_auth.password);
+#else
+       {
+               static struct strbuf up = STRBUF_INIT;
+               strbuf_reset(&up);
                strbuf_addf(&up, "%s:%s",
                            http_auth.username, http_auth.password);
-               curl_easy_setopt(result, CURLOPT_USERPWD,
-                                strbuf_detach(&up, NULL));
+               curl_easy_setopt(result, CURLOPT_USERPWD, up.buf);
        }
+#endif
 }
 
 static int has_cert_password(void)
@@ -494,6 +503,8 @@ struct active_request_slot *get_active_slot(void)
        curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
        curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
        curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
+       if (http_auth.password)
+               init_curl_http_auth(slot->curl);
 
        return slot;
 }
@@ -829,7 +840,7 @@ int http_get_strbuf(const char *url, struct strbuf *result, int options)
 }
 
 /*
- * Downloads an url and stores the result in the given file.
+ * Downloads a URL and stores the result in the given file.
  *
  * If a previous interrupted download is detected (i.e. a previous temporary
  * file is still around) the download is resumed.