summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: df00521)
raw | patch | inline | side by side (parent: df00521)
author | Tay Ray Chuan <rctay89@gmail.com> | |
Sat, 6 Jun 2009 08:43:41 +0000 (16:43 +0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 6 Jun 2009 17:56:27 +0000 (10:56 -0700) |
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>
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>
http-push.c | patch | blob | history | |
http-walker.c | patch | blob | history | |
http.c | patch | blob | history | |
http.h | patch | blob | history |
diff --git a/http-push.c b/http-push.c
index 281e153eb3655d0aa2b94d62a292672ae6ef768e..f18da2a26334e6ea00b61cba572d25e4aa92e9c3 100644 (file)
--- a/http-push.c
+++ b/http-push.c
#endif
#define PREV_BUF_SIZE 4096
-#define RANGE_HEADER_SIZE 30
/* DAV methods */
#define DAV_LOCK "LOCK"
static int aborted;
static signed char remote_dir_exists[256];
-static struct curl_slist *no_pragma_header;
-
static int push_verbosely;
static int push_all = MATCH_REFS_NONE;
static int force_all;
}
if (!strcmp(arg, "--verbose")) {
push_verbosely = 1;
+ http_is_verbose = 1;
continue;
}
if (!strcmp(arg, "-d")) {
remote->url[remote->url_nr++] = repo->url;
http_init(remote);
- no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
-
if (repo->url && repo->url[strlen(repo->url)-1] != '/') {
rewritten_url = xmalloc(strlen(repo->url)+2);
strcpy(rewritten_url, repo->url);
unlock_remote(info_ref_lock);
free(repo);
- curl_slist_free_all(no_pragma_header);
-
http_cleanup();
request = request_queue_head;
diff --git a/http-walker.c b/http-walker.c
index d6cc622e96d2aaa8ece45c517729b2d949471f4b..032a7be62ea1b21d97e444fe9e3d38f22fe6a24f 100644 (file)
--- a/http-walker.c
+++ b/http-walker.c
#include "http.h"
#define PREV_BUF_SIZE 4096
-#define RANGE_HEADER_SIZE 30
struct alt_base
{
const char *url;
int got_alternates;
struct alt_base *alt;
- struct curl_slist *no_pragma_header;
};
static struct object_request *object_queue_head;
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);
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
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;
/*
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)
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);
index 2e3d6493ef40e1b34fea8d166d760f0b1fcccafc..3ca60bb8f9f0e42966047205782c71ccb98a0cdb 100644 (file)
--- a/http.c
+++ b/http.c
int data_received;
int active_requests;
+int http_is_verbose;
#ifdef USE_CURL_MULTI
static int max_requests = -1;
static struct curl_slist *pragma_header;
+struct curl_slist *no_pragma_header;
+
static struct active_request_slot *active_queue_head;
size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *buffer_)
char *low_speed_limit;
char *low_speed_time;
+ http_is_verbose = 0;
+
git_config(http_options, NULL);
curl_global_init(CURL_GLOBAL_ALL);
curl_http_proxy = xstrdup(remote->http_proxy);
pragma_header = curl_slist_append(pragma_header, "Pragma: no-cache");
+ no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
#ifdef USE_CURL_MULTI
{
curl_slist_free_all(pragma_header);
pragma_header = NULL;
+ curl_slist_free_all(no_pragma_header);
+ no_pragma_header = NULL;
+
if (curl_http_proxy) {
free((void *)curl_http_proxy);
curl_http_proxy = NULL;
index 26abebed1f35db971e423f79c433bed8c5338789..1ef7dc158356ec67ae7cbc0702f5c0392690609f 100644 (file)
--- a/http.h
+++ b/http.h
extern void step_active_slots(void);
#endif
+extern struct curl_slist *no_pragma_header;
+
+#define RANGE_HEADER_SIZE 30
+
extern void http_init(struct remote *remote);
extern void http_cleanup(void);
extern int data_received;
extern int active_requests;
+extern int http_is_verbose;
extern char curl_errorstr[CURL_ERROR_SIZE];