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 [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=78316 --- shadow/78316 2006-05-06 16:37:21.000000000 -0400 +++ shadow/78316.tmp.8152 2006-05-06 16:37:21.000000000 -0400 @@ -0,0 +1,145 @@ +Bug#: 78316 +Product: Mono: Class Libraries +Version: 1.1 +OS: other +OS Details: Red Hat Enterprise Linux 4 +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: System +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Incorrect behavior of System.Net.HttpListenerResponse.Close + +According to the Framework SDK documentation, +System.Net.HttpListenerResponse.Close "sends the response to the client and +releases the resources held by this HttpListenerResponse instance". The +Mono implementation however requires the caller to write zero bytes to the +output stream if a zero-length response is desired. As a result, the +client-side fails. + +The enclosed testcase can be used to reproduce the problem. +A proposed fix is attached. + +Steps to reproduce the problem: +1. mono server.exe +2. mono client.exe + +Actual Results: + +HttpListenerResponse.Close does not send the response to the client. The +client fails with an exception: + +Unhandled Exception: System.Net.WebException: Error getting response stream +(ReadDone2): ReceiveFailure ---> System.Exception: + at System.Net.WebConnection.HandleError () + at System.Net.WebConnection.ReadDone () + at System.MulticastDelegate.invoke_void_IAsyncResult () + at System.Net.Sockets.Socket+SocketAsyncResult.Complete () + at System.Net.Sockets.Socket+Worker.Receive () + at System.MulticastDelegate.invoke_void () +in <0x000ad> System.Net.WebConnection:HandleError (WebExceptionStatus st, +System.Exception e, System.String where)--- End of inner exception stack +trace --- + +in <0x00158> System.Net.HttpWebRequest:EndGetResponse (IAsyncResult +asyncResult) +in <0x00047> System.Net.HttpWebRequest:GetResponse () +in <0x000c0> Client:Main () + +Expected Results: + +If the response body is empty because the caller did not write to the +output stream, HttpListenerResponse must send a valid HTTP response with an +empty response body and a content length of zero or a chunked response +containing an empty chunk. + +How often does this happen? + +100 out of 100 times + +Additional Information: + +The following testcase can be used to reproduce the problem. Compiling +server.cs without additional defines triggers the issue. Compiling with +/d:WORKAROUND enables a workaround. + +client.cs: + +using System; +using System.IO; +using System.Net; + +public class Client +{ + public static void Main() + { + Uri uri = new Uri("http://localhost:8080/"); + byte[] buf = new byte[100]; + + while (true) { + WebRequest req = WebRequest.CreateDefault(uri); + req.Method = "POST"; + req.ContentLength = buf.Length; + + Stream stream = req.GetRequestStream(); + stream.Write(buf, 0, buf.Length); + stream.Close(); + + WebResponse response = req.GetResponse(); + response.Close(); + } + } +} + +server.cs: + +using System; +using System.IO; +using System.Net; + +public class Server +{ + public static void Main() + { + HttpListener listener = new HttpListener(); + listener.Prefixes.Add("http://localhost:8080/"); + listener.Start(); + + byte[] buf = new byte[100]; + long start = DateTime.UtcNow.Ticks; + int count = 0; + + while (true) { + HttpListenerContext ctx = listener.GetContext(); + Stream stream = ctx.Request.InputStream; + stream.Read(buf, 0, 100); + stream.Close(); + + HttpListenerResponse response = ctx.Response; + response.StatusCode = 200; + response.ContentLength64 = 0; + +#if WORKAROUND + Stream outputStream = response.OutputStream; + outputStream.Write(buf, 0, 0); + outputStream.Close(); +#endif + response.Close(); + + long end = DateTime.UtcNow.Ticks; + count++; + + if (end - start >= 10000000L) { + Console.WriteLine("Requests/s: " + count); + start = end; + count = 0; + } + } + } +} _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
