Skip to content

Commit

Permalink
Merge branch 'tc/smart-http-post-redirect'
Browse files Browse the repository at this point in the history
* tc/smart-http-post-redirect:
  smart-http: Don't change POST to GET when following redirect
  • Loading branch information
Junio C Hamano committed Nov 30, 2010
2 parents 3fe9db3 + 311e2ea commit feedaf4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions t/lib-httpd/apache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -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

Expand Down
8 changes: 8 additions & 0 deletions t/t5551-http-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit feedaf4

Please sign in to comment.