From 45c1741235a1fbd54484fa1c67ea68569dcfa23e Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 10 Sep 2007 23:02:28 -0400 Subject: Refactor http.h USE_CURL_MULTI fill_active_slots(). This removes all of the boilerplate and http-internal stuff from fill_active_slots() and makes it easy to turn into a callback. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- http.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'http.h') diff --git a/http.h b/http.h index 69b6b667d9..559105cc03 100644 --- a/http.h +++ b/http.h @@ -71,6 +71,9 @@ extern void release_active_slot(struct active_request_slot *slot); #ifdef USE_CURL_MULTI extern void fill_active_slots(void); extern void step_active_slots(void); + +/* Provided by the program using http. */ +extern int fill_active_slot(void); #endif extern void http_init(void); @@ -79,10 +82,6 @@ extern void http_cleanup(void); extern int data_received; extern int active_requests; -#ifdef USE_CURL_MULTI -extern int max_requests; -extern CURLM *curlm; -#endif #ifndef NO_CURL_EASY_DUPHANDLE extern CURL *curl_default; #endif @@ -103,6 +102,4 @@ extern long curl_low_speed_time; extern struct curl_slist *pragma_header; extern struct curl_slist *no_range_header; -extern struct active_request_slot *active_queue_head; - #endif /* HTTP_H */ -- cgit v1.2.3 From fc57b6aaa5bc59ecbe0c052b98196a93b35760a5 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 10 Sep 2007 23:02:34 -0400 Subject: Make function to refill http queue a callback This eliminates the last function provided by the code using http.h as a global symbol, so it should be possible to have multiple programs using http.h in the same executable, and it also adds an argument to that callback, so that info can be passed into the callback without being global. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- http.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'http.h') diff --git a/http.h b/http.h index 559105cc03..72abac20f8 100644 --- a/http.h +++ b/http.h @@ -70,10 +70,8 @@ extern void release_active_slot(struct active_request_slot *slot); #ifdef USE_CURL_MULTI extern void fill_active_slots(void); +extern void add_fill_function(void *data, int (*fill)(void *)); extern void step_active_slots(void); - -/* Provided by the program using http. */ -extern int fill_active_slot(void); #endif extern void http_init(void); -- cgit v1.2.3 From cc3530e8f3f512dd407f64caf2c9916cb26afbc2 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sun, 9 Dec 2007 18:04:57 +0100 Subject: Cleanup variables in http.[ch] Quite some variables defined as extern in http.h are only used in http.c, and some others, only defined in http.c, were not static. Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano --- http.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'http.h') diff --git a/http.h b/http.h index 72abac20f8..fe1b0d153b 100644 --- a/http.h +++ b/http.h @@ -80,24 +80,6 @@ extern void http_cleanup(void); extern int data_received; extern int active_requests; -#ifndef NO_CURL_EASY_DUPHANDLE -extern CURL *curl_default; -#endif extern char curl_errorstr[CURL_ERROR_SIZE]; -extern int curl_ssl_verify; -extern char *ssl_cert; -#if LIBCURL_VERSION_NUM >= 0x070902 -extern char *ssl_key; -#endif -#if LIBCURL_VERSION_NUM >= 0x070908 -extern char *ssl_capath; -#endif -extern char *ssl_cainfo; -extern long curl_low_speed_limit; -extern long curl_low_speed_time; - -extern struct curl_slist *pragma_header; -extern struct curl_slist *no_range_header; - #endif /* HTTP_H */ -- cgit v1.2.3 From e8dc37e0e30dbbed532b7471516d1ba5e6e08f27 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Mon, 10 Dec 2007 22:36:09 +0100 Subject: Avoid redundant declaration of missing_target() Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano --- http.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'http.h') diff --git a/http.h b/http.h index fe1b0d153b..b9d6f4823d 100644 --- a/http.h +++ b/http.h @@ -82,4 +82,17 @@ extern int active_requests; extern char curl_errorstr[CURL_ERROR_SIZE]; +static inline int missing__target(int code, int result) +{ + return /* file:// URL -- do we ever use one??? */ + (result == CURLE_FILE_COULDNT_READ_FILE) || + /* http:// and https:// URL */ + (code == 404 && result == CURLE_HTTP_RETURNED_ERROR) || + /* ftp:// URL */ + (code == 550 && result == CURLE_FTP_COULDNT_RETR_FILE) + ; +} + +#define missing_target(a) missing__target((a)->http_code, (a)->curl_result) + #endif /* HTTP_H */ -- cgit v1.2.3 From 028c2976389f70e7349bbfeeef0ed0a000d5e447 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sun, 9 Dec 2007 20:30:59 +0100 Subject: Use strbuf in http code Also, replace whitespaces with tabs in some places Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano --- http.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'http.h') diff --git a/http.h b/http.h index b9d6f4823d..1528d4196f 100644 --- a/http.h +++ b/http.h @@ -6,6 +6,8 @@ #include #include +#include "strbuf.h" + #if LIBCURL_VERSION_NUM >= 0x071000 #define USE_CURL_MULTI #define DEFAULT_MAX_REQUESTS 5 @@ -48,18 +50,17 @@ struct active_request_slot struct buffer { - size_t posn; - size_t size; - void *buffer; + struct strbuf buf; + size_t posn; }; /* Curl request read/write callbacks */ extern size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, struct buffer *buffer); extern size_t fwrite_buffer(const void *ptr, size_t eltsize, - size_t nmemb, struct buffer *buffer); + size_t nmemb, struct strbuf *buffer); extern size_t fwrite_null(const void *ptr, size_t eltsize, - size_t nmemb, struct buffer *buffer); + size_t nmemb, struct strbuf *buffer); /* Slot lifecycle functions */ extern struct active_request_slot *get_active_slot(void); -- cgit v1.2.3 From d7e92806cdc5ca78c4db879c68f91c70ff9e1ade Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 11 Dec 2007 00:08:25 +0100 Subject: Move fetch_ref from http-push.c and http-walker.c to http.c Make the necessary changes to be ok with their difference, and rename the function http_fetch_ref. Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano --- http.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'http.h') diff --git a/http.h b/http.h index 1528d4196f..aeba9301f8 100644 --- a/http.h +++ b/http.h @@ -96,4 +96,6 @@ static inline int missing__target(int code, int result) #define missing_target(a) missing__target((a)->http_code, (a)->curl_result) +extern int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1); + #endif /* HTTP_H */ -- cgit v1.2.3 From 4f5f998fbd64c997ea875d69fd86b6362e04ce9b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 21 Jan 2008 17:34:43 -0800 Subject: Clarify that http-push being temporarily disabled with older cURL Signed-off-by: Junio C Hamano --- http.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'http.h') diff --git a/http.h b/http.h index aeba9301f8..9bab2c8821 100644 --- a/http.h +++ b/http.h @@ -8,6 +8,14 @@ #include "strbuf.h" +/* + * We detect based on the cURL version if multi-transfer is + * usable in this implementation and define this symbol accordingly. + * This is not something Makefile should set nor users should pass + * via CFLAGS. + */ +#undef USE_CURL_MULTI + #if LIBCURL_VERSION_NUM >= 0x071000 #define USE_CURL_MULTI #define DEFAULT_MAX_REQUESTS 5 -- cgit v1.2.3