summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2010-12-09 10:36:04 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-12-09 10:36:04 -0800
commitd3334d9c444a22847e7add0f60c2e4a7243c151e (patch)
tree022c463650d3f09339a66d6529f0b579c766f19a
parentMerge branch 'ab/require-perl-5.8' into maint (diff)
parentsmart-http: Don't change POST to GET when following redirect (diff)
downloadtgif-d3334d9c444a22847e7add0f60c2e4a7243c151e.tar.xz
Merge branch 'tc/smart-http-post-redirect' into maint
* tc/smart-http-post-redirect: smart-http: Don't change POST to GET when following redirect
-rw-r--r--http.c5
-rw-r--r--t/lib-httpd/apache.conf7
-rwxr-xr-xt/t5551-http-fetch.sh8
3 files changed, 20 insertions, 0 deletions
diff --git a/http.c b/http.c
index 0a5011f615..17bcf19c50 100644
--- a/http.c
+++ b/http.c
@@ -279,6 +279,11 @@ static CURL *get_curl_handle(void)
}
curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
+#if LIBCURL_VERSION_NUM >= 0x071301
+ curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
+#elif LIBCURL_VERSION_NUM >= 0x071101
+ curl_easy_setopt(result, CURLOPT_POST301, 1);
+#endif
if (getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index 4961505d1d..f41c7c674c 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -17,6 +17,9 @@ ErrorLog error.log
<IfModule !mod_env.c>
LoadModule env_module modules/mod_env.so
</IfModule>
+<IfModule !mod_rewrite.c>
+ LoadModule rewrite_module modules/mod_rewrite.so
+</IFModule>
Alias /dumb/ www/
@@ -36,6 +39,10 @@ ScriptAlias /smart_noexport/ ${GIT_EXEC_PATH}/git-http-backend/
Options ExecCGI
</Files>
+RewriteEngine on
+RewriteRule ^/smart-redir-perm/(.*)$ /smart/$1 [R=301]
+RewriteRule ^/smart-redir-temp/(.*)$ /smart/$1 [R=302]
+
<IfDefine SSL>
LoadModule ssl_module modules/mod_ssl.so
diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh
index fd19121372..26d355725f 100755
--- a/t/t5551-http-fetch.sh
+++ b/t/t5551-http-fetch.sh
@@ -101,5 +101,13 @@ test_expect_success 'used upload-pack service' '
test_cmp exp act
'
+test_expect_success 'follow redirects (301)' '
+ git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
+'
+
+test_expect_success 'follow redirects (302)' '
+ git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
+'
+
stop_httpd
test_done