[Mono-bugs] [Bug 381223] New: HttpWebResponse.Close() should only close the stream

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Apr 18 05:15:08 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=381223


           Summary: HttpWebResponse.Close() should only close the stream
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: informatique.internet at fiducial.fr
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Today if you call HttpWebResponse.Close(),it'll dispose the HttpWebResponse
object (and Dispose method close the stream...) According to msdn (and
behaviour of my test case on MS.NET 1.1) HttpWebResponse.Close() should just
close the stream

Try my test case :

// Main.cs created with MonoDevelop
// User: hubert at 16:41 16/04/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
using System.Web.UI;
using System.Data;
using System.IO;
using System.Net;
using Npgsql;
using NpgsqlTypes;

namespace TestViewState
{
        class MainClass
        {
                public static void Main(string[] args)
                {
                        HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("http://www.google.fr/pipo.aspx");
                        req.Method = "GET";
                        req.Timeout=1000;
                        HttpWebResponse resp;
                        try
                        {
                                resp = (HttpWebResponse)req.GetResponse();      
                        }
                        catch (System.Net.WebException ex)
                        {
                                Console.WriteLine("ex :"+ex);
                                resp = (HttpWebResponse)ex.Response;            
                        }
                        resp.Close();
                        Console.WriteLine(resp.StatusCode);
                        Console.WriteLine(resp.StatusDescription);
                }
        }
}

on mono it does:
ex :System.Net.WebException: The remote server returned an error: (404) Not
Found.
  at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult
result) [0x002c7] in
/home/hubert/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1310 
  at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData
data) [0x00102] in
/home/hubert/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1179 

Unhandled Exception: System.ObjectDisposedException: The object was used after
being disposed.
  at System.Net.HttpWebResponse.CheckDisposed () [0x0000b] in
/home/hubert/mono/mcs/class/System/System.Net/HttpWebResponse.cs:348 
  at System.Net.HttpWebResponse.get_StatusCode () [0x00000] in
/home/hubert/mono/mcs/class/System/System.Net/HttpWebResponse.cs:232 
  at (wrapper remoting-invoke-with-check)
System.Net.HttpWebResponse:get_StatusCode ()
  at TestViewState.MainClass.Main (System.String[] args) [0x0005f] in
/home/hubert/Projects/TestViewState/Main.cs:34 


on MS.NET it does

ex :System.Net.WebException: The remote server returned an error: (404) Not
Found.
  at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult
result) [0x002c7] in
/home/hubert/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1310 
  at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData
data) [0x00102] in
/home/hubert/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1179 

NotFound
NotFound


-- 
Configure bugmail: https://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