aboutsummaryrefslogtreecommitdiff
path: root/http-walker.c
diff options
context:
space:
mode:
authorTay Ray Chuan <rctay89@gmail.com>2009-06-06 16:43:41 +0800
committerJunio C Hamano <gitster@pobox.com>2009-06-06 10:56:27 -0700
commite917674597cc0b345ad2d6e29fd1a03e1039615a (patch)
tree26e4286aff1bf9b6364e56d21314dde48f45b56d /http-walker.c
parentdf005219dd4a4c7c310c1e1ab5946f9ba69cc82d (diff)
downloadgit-e917674597cc0b345ad2d6e29fd1a03e1039615a.tar.gz
git-e917674597cc0b345ad2d6e29fd1a03e1039615a.tar.xz
http*: move common variables and macros to http.[ch]
Move RANGE_HEADER_SIZE to http.h. Create no_pragma_header, the curl header list containing the header "Pragma:" in http.[ch]. It is allocated in http_init, and freed in http_cleanup. This replaces the no_pragma_header in http-push.c, and the no_pragma_header member in walker_data in http-walker.c. Create http_is_verbose. It is to be used by methods in http.c, and is modified at the entry points of http.c's users, namely http-push.c (when parsing options) and http-walker.c (in get_http_walker). Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-walker.c')
-rw-r--r--http-walker.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/http-walker.c b/http-walker.c
index d6cc622e9..032a7be62 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -5,7 +5,6 @@
#include "http.h"
#define PREV_BUF_SIZE 4096
-#define RANGE_HEADER_SIZE 30
struct alt_base
{
@@ -57,7 +56,6 @@ struct walker_data {
const char *url;
int got_alternates;
struct alt_base *alt;
- struct curl_slist *no_pragma_header;
};
static struct object_request *object_queue_head;
@@ -108,7 +106,6 @@ static void start_object_request(struct walker *walker,
char range[RANGE_HEADER_SIZE];
struct curl_slist *range_header = NULL;
struct active_request_slot *slot;
- struct walker_data *data = walker->data;
snprintf(prevfile, sizeof(prevfile), "%s.prev", obj_req->filename);
unlink_or_warn(prevfile);
@@ -205,7 +202,7 @@ static void start_object_request(struct walker *walker,
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, obj_req->errorstr);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
- curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, data->no_pragma_header);
+ curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
/*
* If we have successfully processed data from a previous fetch
@@ -354,6 +351,8 @@ static void prefetch(struct walker *walker, unsigned char *sha1)
newreq->slot = NULL;
newreq->next = NULL;
+ http_is_verbose = walker->get_verbosely;
+
if (object_queue_head == NULL) {
object_queue_head = newreq;
} else {
@@ -379,7 +378,6 @@ static int fetch_index(struct walker *walker, struct alt_base *repo, unsigned ch
long prev_posn = 0;
char range[RANGE_HEADER_SIZE];
struct curl_slist *range_header = NULL;
- struct walker_data *data = walker->data;
FILE *indexfile;
struct active_request_slot *slot;
@@ -430,7 +428,7 @@ static int fetch_index(struct walker *walker, struct alt_base *repo, unsigned ch
curl_easy_setopt(slot->curl, CURLOPT_FILE, indexfile);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
- curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, data->no_pragma_header);
+ curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
slot->local = indexfile;
/*
@@ -768,7 +766,6 @@ static int fetch_pack(struct walker *walker, struct alt_base *repo, unsigned cha
long prev_posn = 0;
char range[RANGE_HEADER_SIZE];
struct curl_slist *range_header = NULL;
- struct walker_data *data = walker->data;
struct active_request_slot *slot;
struct slot_results results;
@@ -802,7 +799,7 @@ static int fetch_pack(struct walker *walker, struct alt_base *repo, unsigned cha
curl_easy_setopt(slot->curl, CURLOPT_FILE, packfile);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
- curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, data->no_pragma_header);
+ curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
slot->local = packfile;
/*
@@ -948,10 +945,7 @@ static int fetch_ref(struct walker *walker, struct ref *ref)
static void cleanup(struct walker *walker)
{
- struct walker_data *data = walker->data;
http_cleanup();
-
- curl_slist_free_all(data->no_pragma_header);
}
struct walker *get_http_walker(const char *url, struct remote *remote)
@@ -962,8 +956,6 @@ struct walker *get_http_walker(const char *url, struct remote *remote)
http_init(remote);
- data->no_pragma_header = curl_slist_append(NULL, "Pragma:");
-
data->alt = xmalloc(sizeof(*data->alt));
data->alt->base = xmalloc(strlen(url) + 1);
strcpy(data->alt->base, url);