[Mono-bugs] [Bug 350621] New: WebClient does not make use of UploadDataCompletedEventArgs.Error
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon Dec 24 14:27:20 EST 2007
https://bugzilla.novell.com/show_bug.cgi?id=350621
Summary: WebClient does not make use of
UploadDataCompletedEventArgs.Error
Product: Mono: Class Libraries
Version: SVN
Platform: All
OS/Version: All
Status: NEW
Severity: Major
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at ximian.com
ReportedBy: jhurliman at metaverseindustries.com
QAContact: mono-bugs at ximian.com
Found By: Other
The following code demonstrates the problem. If the server you are executing an
UploadDataAsync() command to returns an error code, it throws an unhandled
exception somewhere in the mono class libraries that cannot be captured by user
code. Actually throwing the exception is different behavior from .NET though,
it seems the correct behavior is to fire the callback with
UploadDataCompletedEventArgs.Error set to the exception that occurred.
using System;
using System.Net;
namespace webclientbug
{
class webclientbug
{
const string URI = "http://www.google.com/";
static void Main(string[] args)
{
// Some random bytes. Google will return a 501 so this isn't
important
byte[] data = new byte[] { 0x01, 0x01, 0x01, 0x01 };
WebClient request = new WebClient();
request.UploadProgressChanged += new
UploadProgressChangedEventHandler(request_UploadProgressChanged);
request.UploadDataCompleted += new
UploadDataCompletedEventHandler(request_UploadDataCompleted);
try { request.UploadDataAsync(new Uri(URI), data); }
catch (Exception) { Console.WriteLine("Caught the exception!"); }
System.Threading.Thread.Sleep(10000);
}
static void request_UploadProgressChanged(object sender,
UploadProgressChangedEventArgs e)
{
Console.WriteLine("Upload progress changed");
}
static void request_UploadDataCompleted(object sender,
UploadDataCompletedEventArgs e)
{
Console.WriteLine("Upload data completed");
}
}
}
Expected Output:
Either "Caught the exception!" or firing the callback with
UploadDataCompletedEventArgs.Error set to the 501 error, which would just print
"Upload data completed" in this example.
Actual Output:
Unhandled Exception: System.Net.WebException: The remote server returned an
error: (501) Not Implemented.
at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult
result) [0x00000]
at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData
data) [0x00000]
--
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