From 033a2536df5c369edec36e86d707a326d838a8ff Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Mon, 30 Apr 2012 14:16:21 -0400 Subject: [PATCH] .NET 4.0+ flushes the request stream when content length is not set Fixes bug #4640 --- mcs/class/System/System.Net/HttpWebRequest.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/System.Net/HttpWebRequest.cs b/mcs/class/System/System.Net/HttpWebRequest.cs index 2c224a9df09..4b8f5aaa6eb 100644 --- a/mcs/class/System/System.Net/HttpWebRequest.cs +++ b/mcs/class/System/System.Net/HttpWebRequest.cs @@ -822,8 +822,18 @@ namespace System.Net void CheckIfForceWrite () { - if (writeStream == null || writeStream.RequestWritten || (contentLength < 0 && writeStream.CanWrite == true) || !InternalAllowBuffering) + if (writeStream == null || writeStream.RequestWritten || !InternalAllowBuffering) return; +#if NET_4_0 + if (contentLength < 0 && writeStream.CanWrite == true && writeStream.WriteBufferLength <= 0) + return; + + if (contentLength < 0 && writeStream.WriteBufferLength > 0) + InternalContentLength = writeStream.WriteBufferLength; +#else + if (contentLength < 0 && writeStream.CanWrite == true) + return; +#endif // This will write the POST/PUT if the write stream already has the expected // amount of bytes in it (ContentLength) (bug #77753) or if the write stream -- 2.25.1