Skip to content

Commit d3334d9

Browse files
committed
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
2 parents fa8f1ca + 311e2ea commit d3334d9

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

http.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ static CURL *get_curl_handle(void)
279279
}
280280

281281
curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
282+
#if LIBCURL_VERSION_NUM >= 0x071301
283+
curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
284+
#elif LIBCURL_VERSION_NUM >= 0x071101
285+
curl_easy_setopt(result, CURLOPT_POST301, 1);
286+
#endif
282287

283288
if (getenv("GIT_CURL_VERBOSE"))
284289
curl_easy_setopt(result, CURLOPT_VERBOSE, 1);

t/lib-httpd/apache.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ ErrorLog error.log
1717
<IfModule !mod_env.c>
1818
LoadModule env_module modules/mod_env.so
1919
</IfModule>
20+
<IfModule !mod_rewrite.c>
21+
LoadModule rewrite_module modules/mod_rewrite.so
22+
</IFModule>
2023

2124
Alias /dumb/ www/
2225

@@ -36,6 +39,10 @@ ScriptAlias /smart_noexport/ ${GIT_EXEC_PATH}/git-http-backend/
3639
Options ExecCGI
3740
</Files>
3841

42+
RewriteEngine on
43+
RewriteRule ^/smart-redir-perm/(.*)$ /smart/$1 [R=301]
44+
RewriteRule ^/smart-redir-temp/(.*)$ /smart/$1 [R=302]
45+
3946
<IfDefine SSL>
4047
LoadModule ssl_module modules/mod_ssl.so
4148

t/t5551-http-fetch.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,13 @@ test_expect_success 'used upload-pack service' '
101101
test_cmp exp act
102102
'
103103

104+
test_expect_success 'follow redirects (301)' '
105+
git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
106+
'
107+
108+
test_expect_success 'follow redirects (302)' '
109+
git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
110+
'
111+
104112
stop_httpd
105113
test_done

0 commit comments

Comments
 (0)