diff options
author | Gert Driesen <drieseng@users.sourceforge.net> | 2009-07-06 23:58:00 +0400 |
---|---|---|
committer | Gert Driesen <drieseng@users.sourceforge.net> | 2009-07-06 23:58:00 +0400 |
commit | 8d403f038171945e82ca7ce1b66679f038085962 (patch) | |
tree | 54d8dd8aa3ec0eed0cc017d9b94e9eb3b0a38418 /mcs/class | |
parent | ba7a4ef720c1d296393d74ac6ef74de32d5015fb (diff) |
* WebConnectionStream.cs: Move and improve argument checks to match MS.
Modified CanRead and CanWrite to return false when instance is disposed.
* HttpWebRequestTest.cs: Enabled tests, and removed test that is now
covered by two separate CanTimeout tests for request and response
stream.
* HttpWebResponseStreamTest.cs: Enabled tests.
svn path=/trunk/mcs/; revision=137450
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System/System.Net/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System/System.Net/WebConnectionStream.cs | 25 | ||||
-rw-r--r-- | mcs/class/System/Test/System.Net/ChangeLog | 7 | ||||
-rw-r--r-- | mcs/class/System/Test/System.Net/HttpWebRequestTest.cs | 42 | ||||
-rw-r--r-- | mcs/class/System/Test/System.Net/HttpWebResponseTest.cs | 10 |
5 files changed, 30 insertions, 59 deletions
diff --git a/mcs/class/System/System.Net/ChangeLog b/mcs/class/System/System.Net/ChangeLog index c17c79f7f5b..472b2a27b4c 100644 --- a/mcs/class/System/System.Net/ChangeLog +++ b/mcs/class/System/System.Net/ChangeLog @@ -1,3 +1,8 @@ +2009-07-06 Gert Driesen <drieseng@users.sourceforge.net> + + * WebConnectionStream.cs: Move and improve argument checks to match MS. + Modified CanRead and CanWrite to return false when instance is disposed. + 2009-07-02 Gonzalo Paniagua Javier <gonzalo@novell.com> * WebConnection.cs: provide better error message when there's an error diff --git a/mcs/class/System/System.Net/WebConnectionStream.cs b/mcs/class/System/System.Net/WebConnectionStream.cs index 9cda6c424b9..71de529cdad 100644 --- a/mcs/class/System/System.Net/WebConnectionStream.cs +++ b/mcs/class/System/System.Net/WebConnectionStream.cs @@ -307,12 +307,6 @@ namespace System.Net public override int Read (byte [] buffer, int offset, int size) { - if (!isRead) - throw new NotSupportedException ("this stream does not allow reading"); - - if (totalRead >= contentLength) - return 0; - AsyncCallback cb = new AsyncCallback (ReadCallbackWrapper); WebAsyncResult res = (WebAsyncResult) BeginRead (buffer, offset, size, cb, null); if (!res.IsCompleted && !res.WaitUntilComplete (ReadTimeout, false)) { @@ -334,8 +328,10 @@ namespace System.Net throw new ArgumentNullException ("buffer"); int length = buffer.Length; - if (size < 0 || offset < 0 || length < offset || length - offset < size) - throw new ArgumentOutOfRangeException (); + if (offset < 0 || length < offset) + throw new ArgumentOutOfRangeException ("offset"); + if (size < 0 || (length - offset) < size) + throw new ArgumentOutOfRangeException ("size"); lock (locker) { pendingReads++; @@ -467,8 +463,10 @@ namespace System.Net throw new ArgumentNullException ("buffer"); int length = buffer.Length; - if (size < 0 || offset < 0 || length < offset || length - offset < size) - throw new ArgumentOutOfRangeException (); + if (offset < 0 || length < offset) + throw new ArgumentOutOfRangeException ("offset"); + if (size < 0 || (length - offset) < size) + throw new ArgumentOutOfRangeException ("size"); if (sendChunked) { lock (locker) { @@ -591,9 +589,6 @@ namespace System.Net public override void Write (byte [] buffer, int offset, int size) { - if (isRead) - throw new NotSupportedException ("This stream does not allow writing"); - AsyncCallback cb = new AsyncCallback (WriteCallbackWrapper); WebAsyncResult res = (WebAsyncResult) BeginWrite (buffer, offset, size, cb, null); if (!res.IsCompleted && !res.WaitUntilComplete (WriteTimeout, false)) { @@ -778,11 +773,11 @@ namespace System.Net } public override bool CanRead { - get { return isRead; } + get { return !disposed && isRead; } } public override bool CanWrite { - get { return !isRead; } + get { return !disposed && !isRead; } } public override long Length { diff --git a/mcs/class/System/Test/System.Net/ChangeLog b/mcs/class/System/Test/System.Net/ChangeLog index 0d0f4c01e6c..7017382e720 100644 --- a/mcs/class/System/Test/System.Net/ChangeLog +++ b/mcs/class/System/Test/System.Net/ChangeLog @@ -1,5 +1,12 @@ 2009-07-06 Gert Driesen <drieseng@users.sourceforge.net> + * HttpWebRequestTest.cs: Enabled tests, and removed test that is now + covered by two separate CanTimeout tests for request and response + stream. + * HttpWebResponseStreamTest.cs: Enabled tests. + +2009-07-06 Gert Driesen <drieseng@users.sourceforge.net> + * HttpWebRequestTest.cs: Marked test notworking on 1.0 profile. 2009-07-06 Gert Driesen <drieseng@users.sourceforge.net> diff --git a/mcs/class/System/Test/System.Net/HttpWebRequestTest.cs b/mcs/class/System/Test/System.Net/HttpWebRequestTest.cs index b826df9b552..13bf8327b0e 100644 --- a/mcs/class/System/Test/System.Net/HttpWebRequestTest.cs +++ b/mcs/class/System/Test/System.Net/HttpWebRequestTest.cs @@ -1502,38 +1502,6 @@ namespace MonoTests.System.Net } } -#if NET_2_0 - [Test] // bug #324182 -#if TARGET_JVM - [Category ("NotWorking")] -#endif - public void Stream_CanTimeout () - { - IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 8764); - string url = "http://" + localEP.ToString () + "/original/"; - - // allow autoredirect - using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (RedirectRequestHandler))) { - responder.Start (); - - HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url); - req.Method = "POST"; - req.Timeout = 2000; - req.ReadWriteTimeout = 2000; - req.KeepAlive = false; - Stream rs = req.GetRequestStream (); - Assert.IsTrue (rs.CanTimeout, "#1"); - rs.Close (); - using (HttpWebResponse resp = (HttpWebResponse) req.GetResponse ()) { - Stream os = resp.GetResponseStream (); - Assert.IsTrue (os.CanTimeout, "#2"); - os.Close (); - } - responder.Stop (); - } - } -#endif - [Test] // bug #353495 [Category ("NotWorking")] public void LastModifiedKind () @@ -2639,7 +2607,10 @@ namespace MonoTests.System.Net } #if NET_2_0 - [Test] + [Test] // bug #324182 +#if TARGET_JVM + [Category ("NotWorking")] +#endif public void CanTimeout () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -2665,7 +2636,6 @@ namespace MonoTests.System.Net #endif [Test] - [Category ("NotWorking")] public void CanWrite () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -2829,7 +2799,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Write_Count_Negative () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -2860,7 +2829,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Write_Count_Overflow () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -2891,7 +2859,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Write_Offset_Negative () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -2922,7 +2889,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Write_Offset_Overflow () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); diff --git a/mcs/class/System/Test/System.Net/HttpWebResponseTest.cs b/mcs/class/System/Test/System.Net/HttpWebResponseTest.cs index 775ced585bd..dd974917525 100644 --- a/mcs/class/System/Test/System.Net/HttpWebResponseTest.cs +++ b/mcs/class/System/Test/System.Net/HttpWebResponseTest.cs @@ -665,7 +665,10 @@ namespace MonoTests.System.Net } #if NET_2_0 - [Test] + [Test] // bug #324182 +#if TARGET_JVM + [Category ("NotWorking")] +#endif public void CanTimeout () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -764,7 +767,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Read_Buffer_Null () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -816,7 +818,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Read_Count_Negative () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -869,7 +870,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Read_Count_Overflow () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -922,7 +922,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Read_Offset_Negative () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); @@ -975,7 +974,6 @@ namespace MonoTests.System.Net } [Test] - [Category ("NotWorking")] public void Read_Offset_Overflow () { IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000); |