diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs index ee41dbb716adf..b7f911048dca8 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AutoRedirect.cs @@ -44,8 +44,15 @@ public static IEnumerable<object[]> RedirectStatusCodesOldMethodsNewMethods() foreach (int statusCode in new[] { 300, 301, 302, 303, 307, 308 }) { yield return new object[] { statusCode, "GET", "GET" }; - yield return new object[] { statusCode, "POST", statusCode <= 303 ? "GET" : "POST" }; yield return new object[] { statusCode, "HEAD", "HEAD" }; + + yield return new object[] { statusCode, "POST", statusCode <= 303 ? "GET" : "POST" }; + + yield return new object[] { statusCode, "DELETE", statusCode == 303 ? "GET" : "DELETE" }; + yield return new object[] { statusCode, "OPTIONS", statusCode == 303 ? "GET" : "OPTIONS" }; + yield return new object[] { statusCode, "PATCH", statusCode == 303 ? "GET" : "PATCH" }; + yield return new object[] { statusCode, "PUT", statusCode == 303 ? "GET" : "PUT" }; + yield return new object[] { statusCode, "MYCUSTOMMETHOD", statusCode == 303 ? "GET" : "MYCUSTOMMETHOD" }; } } public HttpClientHandlerTest_AutoRedirect(ITestOutputHelper output) : base(output) { } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs index cf1693672b03e..856b4e61da394 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs @@ -142,9 +142,10 @@ private static bool RequestRequiresForceGet(HttpStatusCode statusCode, HttpMetho { case HttpStatusCode.Moved: case HttpStatusCode.Found: - case HttpStatusCode.SeeOther: case HttpStatusCode.MultipleChoices: return requestMethod == HttpMethod.Post; + case HttpStatusCode.SeeOther: + return requestMethod != HttpMethod.Get && requestMethod != HttpMethod.Head; default: return false; }