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
+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
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)) {
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++;
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) {
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)) {
}
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 {
+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.
}
}
-#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 ()
}
#if NET_2_0
- [Test]
+ [Test] // bug #324182
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
public void CanTimeout ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
#endif
[Test]
- [Category ("NotWorking")]
public void CanWrite ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Write_Count_Negative ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Write_Count_Overflow ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Write_Offset_Negative ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Write_Offset_Overflow ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
#if NET_2_0
- [Test]
+ [Test] // bug #324182
+#if TARGET_JVM
+ [Category ("NotWorking")]
+#endif
public void CanTimeout ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Read_Buffer_Null ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Read_Count_Negative ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Read_Count_Overflow ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Read_Offset_Negative ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);
}
[Test]
- [Category ("NotWorking")]
public void Read_Offset_Overflow ()
{
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 8000);