[Mono-bugs] [Bug 510661] New: HttpWebRequest: IOException not wrapped in WebException when request stream cannot be closed

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Jun 5 17:13:25 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=510661


           Summary: HttpWebRequest: IOException not wrapped in
                    WebException when request stream cannot be closed
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gert.driesen at pandora.be
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR
3.0.04506.30; .NET CLR 3.0.04506.590; .NET CLR 3.0.04506.648; .NET CLR
3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

When - for example - the expected content is not yet complete written to the
request stream and you close the stream, then we do not wrap the IOException in
a WebException like MS does.

Reproducible: Always

Steps to Reproduce:
Compile and run the following code:

using System;
using System.IO;
using System.Net;

class Program
{
  static int Main ()
  {
    HttpWebRequest req = (HttpWebRequest) WebRequest.Create (
      new Uri ("http://mono-project.com"));
    req.Method = "POST";
    req.ContentLength = 2;

    Stream rs = req.GetRequestStream ();
    rs.WriteByte (0x2a);
    rs.Close ();
  }
}

Actual Results:  
Unhandled Exception: System.IO.IOException: Cannot close the stream until all
by
tes are written
  at System.Net.WebConnectionStream.Close () [0x00000]
  at Program.Main () [0x00000]

Expected Results:  
Unhandled Exception: System.Net.WebException: The request was aborted: The requ
st was canceled. ---> System.IO.IOException: Cannot close stream until all byte
 are written.
   at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean abor
ing)
   --- End of inner exception stack trace ---
   at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean abor
ing)
   at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeSt
te)
   at System.Net.ConnectStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at Program.Main()

I'll add a unit test named "GetRequestStream_Close_NotAllBytesWritten" to
HttpWebRequestTest.cs later today, and mark it NotWorking.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list