[Http]: Disable redirect with body and no buffering.
authorMartin Baulig <martin.baulig@xamarin.com>
Thu, 3 Apr 2014 23:40:07 +0000 (19:40 -0400)
committerMartin Baulig <martin.baulig@xamarin.com>
Tue, 8 Apr 2014 06:24:40 +0000 (08:24 +0200)
mcs/class/System/System.Net/HttpWebRequest.cs

index 5e1c85296322fb533bc4d483ed4f78dc954ff0ef..0c4be7268f179dfb8eccf898db6a5153865dfbb7 100644 (file)
@@ -1119,7 +1119,7 @@ namespace System.Net
                        sendChunked = false;
                }
                
-               bool Redirect (WebAsyncResult result, HttpStatusCode code)
+               bool Redirect (WebAsyncResult result, HttpStatusCode code, WebResponse response)
                {
                        redirects++;
                        Exception e = null;
@@ -1149,6 +1149,9 @@ namespace System.Net
                                break;
                        }
 
+                       if (method != "GET" && !InternalAllowBuffering)
+                               e = new WebException ("The request requires buffering data to succeed.", null, WebExceptionStatus.ProtocolError, webResponse);
+
                        if (e != null)
                                throw e;
 
@@ -1716,7 +1719,7 @@ namespace System.Net
                                bool b = false;
                                int c = (int) code;
                                if (allowAutoRedirect && c >= 300) {
-                                       b = Redirect (result, code);
+                                       b = Redirect (result, code, webResponse);
                                        if (InternalAllowBuffering && writeStream.WriteBufferLength > 0) {
                                                bodyBuffer = writeStream.WriteBuffer;
                                                bodyBufferLength = writeStream.WriteBufferLength;