@matheusbsbs / matheus-bagliano / commits / 0312600648
Fork 0

Restore functionality to allow proxies to cache objects

The parallel request changes didn't properly implement the previous patch to allow caching of retrieved objects by proxy servers. Restore the previous functionality such that by default requests include the "Pragma: no-cache" header, and this header is removed on requests for pack indexes, packs, and objects. Signed-off-by: Nick Hengeveld <nickh@reactrix.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Nick Hengeveld committed Oct 10, 2005 at 23:22 UTC 031260064840e6e8c6bc36d7856a091ba80330c2
1 file changed +7 -1
http-fetch.c
+7 -1
@@ -29,6 +29,7 @@ static int max_requests = DEFAULT_MAX_REQUESTS;
29 static CURLM *curlm;
30 #endif
31 static CURL *curl_default;
32 +static struct curl_slist *pragma_header;
33 static struct curl_slist *no_pragma_header;
34 static struct curl_slist *no_range_header;
35 static char curl_errorstr[CURL_ERROR_SIZE];
@@ -203,7 +204,7 @@ struct active_request_slot *get_active_slot()
204 slot->in_use = 1;
205 slot->done = 0;
206 slot->local = NULL;
206 - curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
207 + curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header);
208 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_range_header);
209 curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, curl_errorstr);
210
@@ -358,6 +359,7 @@ void start_request(struct transfer_request *request)
359 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
360 curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, request->errorstr);
361 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
362 + curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
363
364 /* If we have successfully processed data from a previous fetch
365 attempt, only fetch the data we don't already have. */
@@ -568,6 +570,7 @@ static int fetch_index(struct alt_base *repo, unsigned char *sha1)
570 curl_easy_setopt(slot->curl, CURLOPT_FILE, indexfile);
571 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
572 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
573 + curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
574 slot->local = indexfile;
575
576 /* If there is data present from a previous transfer attempt,
@@ -837,6 +840,7 @@ static int fetch_pack(struct alt_base *repo, unsigned char *sha1)
840 curl_easy_setopt(slot->curl, CURLOPT_FILE, packfile);
841 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
842 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
843 + curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
844 slot->local = packfile;
845
846 /* If there is data present from a previous transfer attempt,
@@ -1067,6 +1071,7 @@ int main(int argc, char **argv)
1071 return 1;
1072 }
1073 #endif
1074 + pragma_header = curl_slist_append(pragma_header, "Pragma: no-cache");
1075 no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
1076 no_range_header = curl_slist_append(no_range_header, "Range:");
1077
@@ -1106,6 +1111,7 @@ int main(int argc, char **argv)
1111 if (pull(commit_id))
1112 return 1;
1113
1114 + curl_slist_free_all(pragma_header);
1115 curl_slist_free_all(no_pragma_header);
1116 curl_slist_free_all(no_range_header);
1117 curl_easy_cleanup(curl_default);