diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2004-07-12 05:46:57 +0400 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2004-07-12 05:46:57 +0400 |
commit | d9777b761c7162a9d03c017d9f44769adeef1f8d (patch) | |
tree | 5c91dd1998d8e0fcb60b4dfb057383554e3b5eda /mcs/class | |
parent | 5445d60203be092850b4ff49e131324685d71219 (diff) |
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.
svn path=/branches/mono-1-0/mcs/; revision=31026
Diffstat (limited to 'mcs/class')
-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 (); } |