Merge branch 'jk/maint-http-init-not-in-result-handler'
[git.git] / http.c
diff --git a/http.c b/http.c
index 0a743451557b8ea8ef36deeb2e7bbbda72b47344..98c0b2b362c531234ac9d02d922d23958f6d90cf 100644 (file)
--- a/http.c
+++ b/http.c
@@ -4,6 +4,7 @@
 #include "run-command.h"
 #include "url.h"
 #include "credential.h"
+#include "version.h"
 
 int active_requests;
 int http_is_verbose;
@@ -299,7 +300,7 @@ static CURL *get_curl_handle(void)
                curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
 
        curl_easy_setopt(result, CURLOPT_USERAGENT,
-               user_agent ? user_agent : GIT_HTTP_USER_AGENT);
+               user_agent ? user_agent : git_user_agent());
 
        if (curl_ftp_no_epsv)
                curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
@@ -760,10 +761,12 @@ int handle_curl_result(struct slot_results *results)
                        return HTTP_REAUTH;
                }
        } else {
+#if LIBCURL_VERSION_NUM >= 0x070c00
                if (!curl_errorstr[0])
                        strlcpy(curl_errorstr,
                                curl_easy_strerror(results->curl_result),
                                sizeof(curl_errorstr));
+#endif
                return HTTP_ERROR;
        }
 }
@@ -812,6 +815,7 @@ static int http_request(const char *url, void *result, int target, int options)
 
        curl_easy_setopt(slot->curl, CURLOPT_URL, url);
        curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
+       curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "gzip");
 
        if (start_active_slot(slot)) {
                run_active_slot(slot);
@@ -919,7 +923,7 @@ static char *fetch_pack_index(unsigned char *sha1, const char *base_url)
        tmp = strbuf_detach(&buf, NULL);
 
        if (http_get_file(url, tmp, 0) != HTTP_OK) {
-               error("Unable to get pack index %s\n", url);
+               error("Unable to get pack index %s", url);
                free(tmp);
                tmp = NULL;
        }