Add --verbose to git-archive
[gitweb.git] / http.c
diff --git a/http.c b/http.c
index 9604e3326bbc902aed987d2816fdf25450203633..6c1937b676ecd584cededed1c82df30448046ebe 100644 (file)
--- a/http.c
+++ b/http.c
@@ -25,7 +25,6 @@ long curl_low_speed_limit = -1;
 long curl_low_speed_time = -1;
 
 struct curl_slist *pragma_header;
-struct curl_slist *no_range_header;
 
 struct active_request_slot *active_queue_head = NULL;
 
@@ -35,7 +34,7 @@ size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb,
        size_t size = eltsize * nmemb;
        if (size > buffer->size - buffer->posn)
                size = buffer->size - buffer->posn;
-       memcpy(ptr, buffer->buffer + buffer->posn, size);
+       memcpy(ptr, (char *) buffer->buffer + buffer->posn, size);
        buffer->posn += size;
        return size;
 }
@@ -50,7 +49,7 @@ size_t fwrite_buffer(const void *ptr, size_t eltsize,
                        buffer->size = buffer->posn + size;
                buffer->buffer = xrealloc(buffer->buffer, buffer->size);
        }
-       memcpy(buffer->buffer + buffer->posn, ptr, size);
+       memcpy((char *) buffer->buffer + buffer->posn, ptr, size);
        buffer->posn += size;
        data_received++;
        return size;
@@ -195,6 +194,8 @@ static CURL* get_curl_handle(void)
        if (getenv("GIT_CURL_VERBOSE"))
                curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
 
+       curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);
+
        return result;
 }
 
@@ -206,7 +207,6 @@ void http_init(void)
        curl_global_init(CURL_GLOBAL_ALL);
 
        pragma_header = curl_slist_append(pragma_header, "Pragma: no-cache");
-       no_range_header = curl_slist_append(no_range_header, "Range:");
 
 #ifdef USE_CURL_MULTI
        {
@@ -286,7 +286,8 @@ void http_cleanup(void)
        curl_multi_cleanup(curlm);
 #endif
        curl_global_cleanup();
-       
+
+       curl_slist_free_all(pragma_header);
 }
 
 struct active_request_slot *get_active_slot(void)
@@ -342,9 +343,14 @@ struct active_request_slot *get_active_slot(void)
        slot->finished = NULL;
        slot->callback_data = NULL;
        slot->callback_func = NULL;
+       curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
        curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header);
-       curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_range_header);
        curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, curl_errorstr);
+       curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, NULL);
+       curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, NULL);
+       curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
+       curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
+       curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
 
        return slot;
 }
@@ -433,11 +439,15 @@ void release_active_slot(struct active_request_slot *slot)
 {
        closedown_active_slot(slot);
        if (slot->curl) {
+#ifdef USE_CURL_MULTI
                curl_multi_remove_handle(curlm, slot->curl);
+#endif
                curl_easy_cleanup(slot->curl);
                slot->curl = NULL;
        }
+#ifdef USE_CURL_MULTI
        fill_active_slots();
+#endif
 }
 
 static void finish_active_slot(struct active_request_slot *slot)