Browse Source

HttpWebRequest: Only add "Content-Length" if we have a body; fixes #17736.

Martin Baulig 12 years ago
parent
commit
8f2d3ea31d
1 changed files with 2 additions and 1 deletions
  1. 2 1
      mcs/class/System/System.Net/HttpWebRequest.cs

+ 2 - 1
mcs/class/System/System.Net/HttpWebRequest.cs

@@ -1179,7 +1179,8 @@ namespace System.Net
 					if (contentLength > 0)
 						continue100 = true;
 
-					webHeaders.SetInternal ("Content-Length", contentLength.ToString ());
+					if (gotRequestStream || contentLength > 0)
+						webHeaders.SetInternal ("Content-Length", contentLength.ToString ());
 				}
 				webHeaders.RemoveInternal ("Transfer-Encoding");
 			} else {