[Mono-bugs] [Bug 508027] HttpWebRequest.BeginGetResponseStream throws ProtocolViolationException
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Jun 5 19:10:51 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=508027
User gert.driesen at pandora.be added comment
http://bugzilla.novell.com/show_bug.cgi?id=508027#c2
Gert Driesen <gert.driesen at pandora.be> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |gert.driesen at pandora.be
Resolution|FIXED |
--- Comment #2 from Gert Driesen <gert.driesen at pandora.be> 2009-06-05 17:10:50 MDT ---
According to the MSDN doc page for HttpWebRequest.BeginGetResponse, a
ProtocolViolationException is thrown in the following conditions:
Method is GET or HEAD, and either ContentLength is greater than zero or
SendChunked is true.
-or-
KeepAlive is true, AllowWriteStreamBuffering is false, and either ContentLength
is -1 or SendChunked is false, and Method is POST or PUT.
However, starting from .NET 2.0 that exception is no longer thrown in any of
these conditions.
I've filed a (documentation) bug report against MS for this:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=464686
To reproduce, compile and run the following code:
using System;
using System.Net;
class Program
{
static void Main ()
{
Uri url = new Uri ("http://www.microsoft.com");
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.SendChunked = false;
req.KeepAlive = true;
req.AllowWriteStreamBuffering = false;
try {
req.BeginGetResponse (null, null);
} catch (ProtocolViolationException ex) {
Console.WriteLine (ex.ToString ());
Console.WriteLine ();
} finally {
req.Abort ();
}
req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.SendChunked = true;
try {
req.BeginGetResponse (null, null);
} catch (ProtocolViolationException ex) {
Console.WriteLine (ex.ToString ());
Console.WriteLine ();
} finally {
req.Abort ();
}
req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.ContentLength = 5;
try {
req.BeginGetResponse (null, null);
} catch (ProtocolViolationException ex) {
Console.WriteLine (ex.ToString ());
Console.WriteLine ();
} finally {
req.Abort ();
}
}
}
Expected result:
1.0 profile / .NET 1.x:
Three ProtocolViolationExceptions are written to stdout.
2.0 profile (and higher):
Successful execution without output to stdout.
--
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