diff options
-rw-r--r-- | mcs/class/System/System.Net/ChangeLog | 8 | ||||
-rw-r--r-- | mcs/class/System/System.Net/WebConnection.cs | 8 | ||||
-rw-r--r-- | mcs/class/System/System.Net/WebConnectionStream.cs | 9 |
3 files changed, 24 insertions, 1 deletions
diff --git a/mcs/class/System/System.Net/ChangeLog b/mcs/class/System/System.Net/ChangeLog index af2f720eeb5..fa6c9b66237 100644 --- a/mcs/class/System/System.Net/ChangeLog +++ b/mcs/class/System/System.Net/ChangeLog @@ -1,3 +1,11 @@ +2004-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * WebConnection.cs: + * WebConnectionStream.cs: when the status code is 1xx, 204 or 304, + "responses MUST NOT include a message-body". We tried to read the + stream even when getting those codes and considered the 0 length + read as a failure. + 2004-07-09 Gonzalo Paniagua Javier <gonzalo@ximian.com> * HttpWebRequest.cs: removed bogus Monitor.Exit. diff --git a/mcs/class/System/System.Net/WebConnection.cs b/mcs/class/System/System.Net/WebConnection.cs index e4026a68fdb..0cde60ba674 100644 --- a/mcs/class/System/System.Net/WebConnection.cs +++ b/mcs/class/System/System.Net/WebConnection.cs @@ -268,6 +268,9 @@ namespace System.Net data.stream = stream; + if (!ExpectContent (data.StatusCode)) + stream.ForceCompletion (); + lock (cnc) { lock (cnc.queue) { if (cnc.queue.Count > 0) { @@ -282,6 +285,11 @@ namespace System.Net data.request.SetResponseData (data); } + static bool ExpectContent (int statusCode) + { + return (statusCode >= 200 && statusCode != 204 && statusCode != 304); + } + internal void GetCertificates () { // here the SSL negotiation have been done diff --git a/mcs/class/System/System.Net/WebConnectionStream.cs b/mcs/class/System/System.Net/WebConnectionStream.cs index 703f35d42b4..3b355a6d93f 100644 --- a/mcs/class/System/System.Net/WebConnectionStream.cs +++ b/mcs/class/System/System.Net/WebConnectionStream.cs @@ -57,6 +57,7 @@ namespace System.Net byte [] headers; bool disposed; bool headersSent; + bool forceCompletion; public WebConnectionStream (WebConnection cnc) { @@ -113,9 +114,15 @@ namespace System.Net get { return (int) writeBuffer.Length; } } + internal void ForceCompletion () + { + forceCompletion = true; + } + internal void CheckComplete () { - if (!nextReadCalled && readBufferSize - readBufferOffset == contentLength) { + bool nrc = nextReadCalled; + if (forceCompletion || (!nrc && readBufferSize - readBufferOffset == contentLength)) { nextReadCalled = true; cnc.NextRead (); } |