summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ba65af9)
raw | patch | inline | side by side (parent: ba65af9)
author | Sergey Vlasov <vsu@altlinux.ru> | |
Tue, 13 Sep 2005 15:38:58 +0000 (19:38 +0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 15 Sep 2005 19:46:30 +0000 (12:46 -0700) |
By default the curl library adds "Pragma: no-cache" header to all
requests, which disables caching by proxy servers. However, most
files in a GIT repository are immutable, and caching them is safe and
could be useful.
This patch removes the "Pragma: no-cache" header from requests for all
files except the pack list (objects/info/packs) and references
(refs/*), which are really mutable and should not be cached.
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Junio C Hamano <junkio@cox.net>
(cherry picked from 3b2a4c46fd5093ec79fb60e1b14b8d4a58c74612 commit)
requests, which disables caching by proxy servers. However, most
files in a GIT repository are immutable, and caching them is safe and
could be useful.
This patch removes the "Pragma: no-cache" header from requests for all
files except the pack list (objects/info/packs) and references
(refs/*), which are really mutable and should not be cached.
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Junio C Hamano <junkio@cox.net>
(cherry picked from 3b2a4c46fd5093ec79fb60e1b14b8d4a58c74612 commit)
http-fetch.c | patch | blob | history |
diff --git a/http-fetch.c b/http-fetch.c
index 4e564fc4532e0a6665eae9e0586a59cba08c668c..1a433a9842d9bd0a6ed8735e60690e1a73bb8ea8 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
#endif
static CURL *curl;
+static struct curl_slist *no_pragma_header;
static char *base;
curl_easy_setopt(curl, CURLOPT_FILE, indexfile);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(curl, CURLOPT_URL, url);
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, no_pragma_header);
if (curl_easy_perform(curl)) {
fclose(indexfile);
curl_easy_setopt(curl, CURLOPT_FILE, &buffer);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
curl_easy_setopt(curl, CURLOPT_URL, url);
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL);
if (curl_easy_perform(curl)) {
return error("Unable to get pack index %s", url);
curl_easy_setopt(curl, CURLOPT_FILE, packfile);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(curl, CURLOPT_URL, url);
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, no_pragma_header);
if (curl_easy_perform(curl)) {
fclose(packfile);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curl, CURLOPT_FILE, NULL);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, no_pragma_header);
url = xmalloc(strlen(base) + 50);
strcpy(url, base);
curl_easy_setopt(curl, CURLOPT_FILE, &buffer);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL);
url = xmalloc(strlen(base) + 6 + strlen(ref));
strcpy(url, base);
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
+ no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
curl_ssl_verify = getenv("GIT_SSL_NO_VERIFY") ? 0 : 1;
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, curl_ssl_verify);
if (pull(commit_id))
return 1;
+ curl_slist_free_all(no_pragma_header);
curl_global_cleanup();
return 0;
}