Browse Source

2005-02-04 Gonzalo Paniagua Javier <[email protected]>

	* HttpWebRequest.cs: send the headers when we're supposed to write
	a POST/PUT but call GetResponse before GetRequestStream.

	* WebConnectionStream.cs: new RequestWritten property.


svn path=/trunk/mcs/; revision=40127
Gonzalo Paniagua Javier 21 years ago
parent
commit
2ded62faa5

+ 7 - 0
mcs/class/System/System.Net/ChangeLog

@@ -1,3 +1,10 @@
+2005-02-04 Gonzalo Paniagua Javier <[email protected]>
+
+	* HttpWebRequest.cs: send the headers when we're supposed to write
+	a POST/PUT but call GetResponse before GetRequestStream.
+
+	* WebConnectionStream.cs: new RequestWritten property.
+
 2005-01-20  Jonathan Pryor  <[email protected]>
 
 	* EndpointPermission.cs: Fix IsSubsetof(hostname) so that the regression 

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

@@ -89,6 +89,7 @@ namespace System.Net
 		bool authCompleted;
 		byte[] bodyBuffer;
 		int bodyBufferLength;
+		bool getResponseCalled;
 #if NET_1_1
 		int maxResponseHeadersLength;
 		static int defaultMaxResponseHeadersLength;
@@ -641,6 +642,7 @@ namespace System.Net
 
 			CommonChecks (send);
 			Monitor.Enter (this);
+			getResponseCalled = true;
 			if (asyncRead != null && !haveResponse) {
 				Monitor.Exit (this);
 				throw new InvalidOperationException ("Cannot re-call start of asynchronous " +
@@ -846,7 +848,7 @@ namespace System.Net
 		string GetHeaders ()
 		{
 			bool continue100 = false;
-			if (gotRequestStream && contentLength != -1) {
+			if (contentLength != -1) {
 				continue100 = true;
 				webHeaders.SetInternal ("Content-Length", contentLength.ToString ());
 				webHeaders.RemoveInternal ("Transfer-Encoding");
@@ -972,6 +974,9 @@ namespace System.Net
 				writeStream.Write (bodyBuffer, 0, bodyBufferLength);
 				bodyBuffer = null;
 				writeStream.Close ();
+			} else if (method == "PUT" || method == "POST") {
+				if (getResponseCalled && !writeStream.RequestWritten)
+					writeStream.WriteRequest ();
 			}
 
 			if (asyncWrite != null) {

+ 4 - 0
mcs/class/System/System.Net/WebConnectionStream.cs

@@ -402,6 +402,10 @@ namespace System.Net
 			}
 		}
 
+		internal bool RequestWritten {
+			get { return requestWritten; }
+		}
+
 		internal void WriteRequest ()
 		{
 			if (requestWritten)