[Mono-bugs] [Bug 43379][Wis] New - Missing WebException.Response property.

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Tue, 20 May 2003 11:14:35 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ben.luckham@bimtech.co.uk.

http://bugzilla.ximian.com/show_bug.cgi?id=43379

--- shadow/43379	Tue May 20 11:14:35 2003
+++ shadow/43379.tmp.2456	Tue May 20 11:14:35 2003
@@ -0,0 +1,87 @@
+Bug#: 43379
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ben.luckham@bimtech.co.uk               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Missing WebException.Response property.
+
+When a call to HttpWebRequest.GetResponse() results in a WebException 
+being thrown, the Response property of this exception is NULL when, 
+in .NET, it is set to an instance of HttpWebResponse. 
+
+This means that it is not possible to determine the HTTP status code 
+returned in MONO (this is indicated by the StatusCode property of the 
+nonexistent HttpWebResponse object).
+
+This is new behaviour in Release 0.24... HttpWebResponse.GetResponse() 
+never used to throw a WebException at all, but this was changed to improve 
+consistency with .NET.
+
+ 
+Steps to reproduce the problem:
+1. Please see sample program
+
+
+Actual Results:
+Unhandled Exception: System.NullReferenceException: A null value was found 
+where an object instance was required
+in <0x00116> 00 .HttpTest:Main (string[])
+
+(Output obtained by running the sample program in MONO 0.24).
+
+
+Expected Results:
+Server returned error: NotFound
+
+(Output obtained by running the sample program in .NET).
+
+
+How often does this happen? 
+Always in MONO, never in .NET.
+
+
+Additional Information:
+
+-----Sample program starts here-----
+using System;
+using System.Net;
+
+public class HttpTest
+{
+	public static void Main(string[] args)
+	{
+		try
+		{
+			HttpWebRequest httpreq = (HttpWebRequest)
+WebRequest.Create("http://www.go-mono.com/not-here.html");
+			HttpWebResponse httpresp = (HttpWebResponse)
+httpreq.GetResponse();
+			
+			// Expect WebException to be thrown by now.
+
+			Console.Out.WriteLine("Eh?... This page shouldn't 
+exist!");
+		}
+		catch (WebException e)
+		{
+			// Something went wrong! So what's the status code?
+			HttpWebResponse badresp = (HttpWebResponse)
+e.Response;
+			Console.Out.WriteLine("Server returned error: " + 
+badresp.StatusCode); // Exception is thrown here, because e.Response is 
+null (at least it is in MONO).
+		}
+	}
+}
+-----Sample program ends here-----