[Mono-bugs] [Bug 77753][Nor] New - HttpWebRequest does not finish
request as expected (possibly only on Windows)
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri Mar 10 03:55:18 EST 2006
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 atsushi at ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=77753
--- shadow/77753 2006-03-10 03:55:17.000000000 -0500
+++ shadow/77753.tmp.13599 2006-03-10 03:55:17.000000000 -0500
@@ -0,0 +1,113 @@
+Bug#: 77753
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: atsushi at ximian.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: HttpWebRequest does not finish request as expected (possibly only on Windows)
+
+HttpWebRequest does not finish request as expected (I tested it only on
+windows for now). Repro code follows:
+
+// Client
+using System;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Xml;
+
+public class Test
+{
+ public static void Main ()
+ {
+ WebRequest req = HttpWebRequest.Create (new Uri ("http://localhost:8080"));
+ string xml = "<test>sample text</test>";
+ byte [] bytes = Encoding.UTF8.GetBytes (xml);
+ req.Method = "POST";
+ req.ContentType = "text/xml; charset=utf-8";
+ req.ContentLength = bytes.Length;
+ Stream stream = req.GetRequestStream ();
+ stream.Write (bytes, 0, bytes.Length);
+ stream.Flush ();
+ Console.WriteLine ("finished output");
+ WebResponse res = req.GetResponse ();
+ string ret = new StreamReader (res.GetResponseStream ()).ReadToEnd ();
+ Console.WriteLine (ret);
+ }
+}
+
+// Listener
+using System;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Xml;
+
+public class Test
+{
+ public static void Main ()
+ {
+ HttpListener listener = new HttpListener ();
+ listener.Prefixes.Add ("http://localhost:8080/");
+ listener.Start ();
+ HttpListenerContext ctx = listener.GetContext ();
+ Console.WriteLine ("received context.");
+ Stream input = ctx.Request.InputStream;
+ StreamReader sr = new StreamReader (input, ctx.Request.ContentEncoding);
+ string s = sr.ReadToEnd ();
+ Console.WriteLine (s);
+ MemoryStream ms = new MemoryStream ();
+ StreamWriter sw = new StreamWriter (ms, Encoding.UTF8);
+ sw.Write (s);
+ sw.Flush ();
+
+ Stream output = ctx.Response.OutputStream;
+ ctx.Response.ContentLength64 = ms.Length;
+ output.Write (ms.GetBuffer (), 0, (int) ms.Length);
+ output.Close ();
+ }
+}
+
+Steps to reproduce the problem:
+(0. make sure that localhost:8080 is available, or change the code.)
+1. compile client and listener as separate executables.
+2. run the listener.
+3. run the client.
+
+Actual Results:
+
+$ mono ./httpclient.exe
+
+finished output
+
+Unhandled Exception: System.Net.WebException: The request timed out
+in <0x00147> System.Net.HttpWebRequest:EndGetResponse (IAsyncResult
+asyncResult)
+
+in <0x00047> System.Net.HttpWebRequest:GetResponse ()
+in <0x000e9> Test:Main ()
+
+Expected Results:
+
+$ ./httpclient.exe
+finished output
+<test>sample text</test>
+
+How often does this happen?
+
+consistently.
+
+Additional Information:
+
+When I ran the listener under mono and the client under MS.NET, they works
+fine. When both under .NET they also work.
More information about the mono-bugs
mailing list