Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrés G. Aragoneses <knocte@gmail.com>2009-06-16 08:21:58 +0400
committerAndrés G. Aragoneses <knocte@gmail.com>2009-06-16 08:21:58 +0400
commitaa75a48a070a6f22d37fb54c894f331855861fe1 (patch)
tree4a0ec9450f7c084d448442734ad2e3788e28b8bc /mcs/class/System
parent677f6012dbd794dca10fd18a8903dd76c7002c75 (diff)
2009-06-16 Andrés G. Aragoneses <aaragoneses@novell.com>
* WebConnection.cs: propagate the exception to the request. * WebException.cs: new internal ctor. * HttpWebRequest.cs: use new ctor to encapsulate the innerException. Fixes #323452. 2009-06-16 Andrés G. Aragoneses <aaragoneses@novell.com> * WebRequestTest.cs: Drop NotWorking attrib, more accurate tests. svn path=/trunk/mcs/; revision=136198
Diffstat (limited to 'mcs/class/System')
-rw-r--r--mcs/class/System/System.Net/ChangeLog7
-rw-r--r--mcs/class/System/System.Net/HttpWebRequest.cs10
-rw-r--r--mcs/class/System/System.Net/WebConnection.cs2
-rw-r--r--mcs/class/System/System.Net/WebException.cs6
-rw-r--r--mcs/class/System/Test/System.Net/ChangeLog4
-rw-r--r--mcs/class/System/Test/System.Net/WebRequestTest.cs10
6 files changed, 31 insertions, 8 deletions
diff --git a/mcs/class/System/System.Net/ChangeLog b/mcs/class/System/System.Net/ChangeLog
index a38948b1b3c..5825038d473 100644
--- a/mcs/class/System/System.Net/ChangeLog
+++ b/mcs/class/System/System.Net/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-16 Andrés G. Aragoneses <aaragoneses@novell.com>
+
+ * WebConnection.cs: propagate the exception to the request.
+ * WebException.cs: new internal ctor.
+ * HttpWebRequest.cs: use new ctor to encapsulate the innerException.
+ Fixes #323452.
+
2009-06-15 Gonzalo Paniagua Javier <gonzalo@novell.com>
* HttpWebRequest.cs: for unknown methods, always send the request once
diff --git a/mcs/class/System/System.Net/HttpWebRequest.cs b/mcs/class/System/System.Net/HttpWebRequest.cs
index 126efda0aee..217c0d62e8d 100644
--- a/mcs/class/System/System.Net/HttpWebRequest.cs
+++ b/mcs/class/System/System.Net/HttpWebRequest.cs
@@ -1074,11 +1074,15 @@ namespace System.Net
if (r != null) {
string msg;
- if (exc == null)
+ WebException wex;
+ if (exc == null) {
msg = "Error: " + status;
- else
+ wex = new WebException (msg, status);
+ } else {
msg = String.Format ("Error: {0} ({1})", status, exc.Message);
- r.SetCompleted (false, new WebException (msg, status));
+ wex = new WebException (msg, exc, status);
+ }
+ r.SetCompleted (false, wex);
r.DoCallback ();
}
}
diff --git a/mcs/class/System/System.Net/WebConnection.cs b/mcs/class/System/System.Net/WebConnection.cs
index af0ec2dae82..72b20cafffa 100644
--- a/mcs/class/System/System.Net/WebConnection.cs
+++ b/mcs/class/System/System.Net/WebConnection.cs
@@ -589,7 +589,7 @@ namespace System.Net
Connect ();
if (status != WebExceptionStatus.Success) {
if (status != WebExceptionStatus.RequestCanceled) {
- request.SetWriteStreamError (status);
+ request.SetWriteStreamError (status, connect_exception);
Close (true);
}
return;
diff --git a/mcs/class/System/System.Net/WebException.cs b/mcs/class/System/System.Net/WebException.cs
index 6c8c295b4c4..be4446b7a0c 100644
--- a/mcs/class/System/System.Net/WebException.cs
+++ b/mcs/class/System/System.Net/WebException.cs
@@ -62,6 +62,12 @@ namespace System.Net
{
this.status = status;
}
+
+ internal WebException (string message, Exception innerException, WebExceptionStatus status)
+ : base (message, innerException)
+ {
+ this.status = status;
+ }
public WebException(string message,
Exception innerException,
diff --git a/mcs/class/System/Test/System.Net/ChangeLog b/mcs/class/System/Test/System.Net/ChangeLog
index 4aa2eff6905..18aeb3fcf2e 100644
--- a/mcs/class/System/Test/System.Net/ChangeLog
+++ b/mcs/class/System/Test/System.Net/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-16 Andrés G. Aragoneses <aaragoneses@novell.com>
+
+ * WebRequestTest.cs: Drop NotWorking attrib, more accurate tests.
+
2009-06-09 Andrés G. Aragoneses <aaragoneses@novell.com>
* WebRequestTest.cs: Added tests for bug #323452.
diff --git a/mcs/class/System/Test/System.Net/WebRequestTest.cs b/mcs/class/System/Test/System.Net/WebRequestTest.cs
index 2b218a0f106..4b5c176e3bd 100644
--- a/mcs/class/System/Test/System.Net/WebRequestTest.cs
+++ b/mcs/class/System/Test/System.Net/WebRequestTest.cs
@@ -328,18 +328,20 @@ namespace MonoTests.System.Net {
}
[Test] //BNC#323452
- [Category ("NotWorking")]
public void TestFailedConnection ()
{
try {
WebRequest.Create ("http://127.0.0.1:0/non-existant.txt").GetResponse ();
Assert.Fail ("Should have raised an exception");
} catch (Exception e) {
- Assert.IsTrue (e is WebException);
+ Assert.IsTrue (e is WebException, "Got " + e.GetType ().Name + ": " + e.Message);
//#if NET_2_0 e.Message == "Unable to connect to the remote server"
//#if NET_1_1 e.Message == "The underlying connection was closed: Unable to connect to the remote server."
+ Assert.AreEqual (((WebException)e).Status, WebExceptionStatus.ConnectFailure);
+
//#if !NET_1_1 (this is not true in .NET 1.x)
+ Assert.IsNotNull (e.InnerException);
Assert.IsTrue (e.InnerException is Socks.SocketException, "InnerException should be SocketException");
//e.Message == "The requested address is not valid in its context 127.0.0.1:0"
//#endif
@@ -349,14 +351,14 @@ namespace MonoTests.System.Net {
[Test] //BNC#323452
public void TestFailedResolution ()
{
- string domain = "thisdomaindoesnotexist.monotestcase.x";
try {
- WebRequest.Create ("http://" + domain + "/non-existant.txt").GetResponse ();
+ WebRequest.Create ("http://thisdomaindoesnotexist.monotestcase.x/non-existant.txt").GetResponse ();
Assert.Fail ("Should have raised an exception");
} catch (Exception e) {
Assert.IsTrue (e is WebException);
//#if NET_2_0 e.Message == "The underlying connection was closed: The remote name could not be resolved."
//#if NET_1_1 e.Message == "The remote name could not be resolved: 'thisdomaindoesnotexist.monotestcase.x'"
+ Assert.AreEqual (((WebException)e).Status, WebExceptionStatus.NameResolutionFailure);
Assert.IsNull (e.InnerException);
}
}