From 526cac9d5a31f994020f7c9b8f57f883d024d063 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 3 Apr 2014 16:43:36 -0400 Subject: [Http]: Clear the 'SendChunked' flag when redirecting. --- mcs/class/System/System.Net/HttpWebRequest.cs | 8 +++++++- mcs/class/System/System.Net/WebConnectionStream.cs | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/System.Net/HttpWebRequest.cs b/mcs/class/System/System.Net/HttpWebRequest.cs index e21e5ecc4d4..5e1c8529632 100644 --- a/mcs/class/System/System.Net/HttpWebRequest.cs +++ b/mcs/class/System/System.Net/HttpWebRequest.cs @@ -56,6 +56,7 @@ namespace System.Net bool allowBuffering = true; X509CertificateCollection certificates; string connectionGroup; + bool haveContentLength; long contentLength = -1; HttpContinueDelegate continueDelegate; CookieContainer cookieContainer; @@ -277,6 +278,7 @@ namespace System.Net throw new ArgumentOutOfRangeException ("value", "Content-Length must be >= 0"); contentLength = value; + haveContentLength = true; } } @@ -1153,6 +1155,10 @@ namespace System.Net contentLength = -1; //bodyBufferLength = 0; //bodyBuffer = null; + if (sendChunked) { + sendChunked = false; + webHeaders.RemoveInternal ("Transfer-Encoding"); + } uriString = webResponse.Headers ["Location"]; if (uriString == null) @@ -1187,7 +1193,7 @@ namespace System.Net if (contentLength > 0) continue100 = true; - if (gotRequestStream || contentLength > 0) + if (haveContentLength || gotRequestStream || contentLength > 0) webHeaders.SetInternal ("Content-Length", contentLength.ToString ()); } webHeaders.RemoveInternal ("Transfer-Encoding"); diff --git a/mcs/class/System/System.Net/WebConnectionStream.cs b/mcs/class/System/System.Net/WebConnectionStream.cs index c1b8084bdee..5a34a3d8124 100644 --- a/mcs/class/System/System.Net/WebConnectionStream.cs +++ b/mcs/class/System/System.Net/WebConnectionStream.cs @@ -514,6 +514,13 @@ namespace System.Net Buffer.BlockCopy (buffer, offset, newBuffer, head.Length, size); Buffer.BlockCopy (crlf, 0, newBuffer, head.Length + size, crlf.Length); + if (allowBuffering) { + if (writeBuffer == null) + writeBuffer = new MemoryStream (); + writeBuffer.Write (buffer, offset, size); + totalWritten += size; + } + buffer = newBuffer; offset = 0; size = chunkSize; -- cgit v1.2.3