[Http]: Remove chunked/etc headers when redirecting a request as GET.
authorMartin Baulig <martin.baulig@xamarin.com>
Wed, 5 Mar 2014 14:45:00 +0000 (15:45 +0100)
committerMartin Baulig <martin.baulig@xamarin.com>
Tue, 8 Apr 2014 06:23:54 +0000 (08:23 +0200)
mcs/class/System/System.Net/HttpWebRequest.cs

index cbf075efa42019e2723f10ae84524c56507b990d..e21e5ecc4d45cc1f1cfe075f430728856d14611d 100644 (file)
@@ -1109,6 +1109,13 @@ namespace System.Net
                        if (continueDelegate != null)
                                continueDelegate (statusCode, headers);
                }
+
+               void RewriteRedirectToGet ()
+               {
+                       method = "GET";
+                       webHeaders.RemoveInternal ("Transfer-Encoding");
+                       sendChunked = false;
+               }
                
                bool Redirect (WebAsyncResult result, HttpStatusCode code)
                {
@@ -1122,12 +1129,12 @@ namespace System.Net
                        case HttpStatusCode.MovedPermanently: // 301
                        case HttpStatusCode.Redirect: // 302
                                if (method == "POST")
-                                       method = "GET";
+                                       RewriteRedirectToGet ();
                                break;
                        case HttpStatusCode.TemporaryRedirect: // 307
                                break;
                        case HttpStatusCode.SeeOther: //303
-                               method = "GET";
+                               RewriteRedirectToGet ();
                                break;
                        case HttpStatusCode.NotModified: // 304
                                return false;