From 311e2ea0062bf09d6f78f5458eeb14dbc6c092ea Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Sat, 25 Sep 2010 12:20:35 +0800 Subject: smart-http: Don't change POST to GET when following redirect For a long time (29508e1 "Isolate shared HTTP request functionality", Fri Nov 18 11:02:58 2005), we've followed HTTP redirects with CURLOPT_FOLLOWLOCATION. However, when the remote HTTP server returns a redirect the default libcurl action is to change a POST request into a GET request while following the redirect, but the remote http backend does not expect that. Fix this by telling libcurl to always keep the request as type POST with CURLOPT_POSTREDIR. For users of libcurl older than 7.19.1, use CURLOPT_POST301 instead, which only follows 301s instead of both 301s and 302s. Signed-off-by: Andreas Schwab Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- http.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'http.c') 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); -- cgit v1.3