http://bugzilla.novell.com/show_bug.cgi?id=577891
http://bugzilla.novell.com/show_bug.cgi?id=577891#c0 Summary: HttpListener incorrect headers parsing under moderate load Classification: Mono Product: Mono: Class Libraries Version: 2.6.x Platform: x86 OS/Version: openSUSE 11.2 Status: NEW Severity: Major Priority: P5 - None Component: System AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- Created an attachment (id=341241) --> (http://bugzilla.novell.com/attachment.cgi?id=341241) HttpListener Server Sample With Headers Dumps User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; ru; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729) When using HttpListener from System.Net namespace I encounter strange bug with HTTP headers parsing. It appears that when HttpListner is operating under some load and HTTP request data is received in small chunks - headers parsing goes wild. For example, Client sends request to the HttpListener with following headers: User-Agent: Test header1: value1,value2 header2: value1,value2 header3: value1 header4: value1 On server side headers are parsed out into following mess: User-Agent: Test header1: value1,value2header1: value1,value2header1: value1,value2 header2: value1,value2header2: value1,value2 header3: value1header2: value1,value2header2: value1,value2 Hint: it appears that HttpListener parsing logic does not expect to receive single single byte chunks of header separators. Reproducible: Sometimes Steps to Reproduce: 1.Start HttpListener and dump headers of every request 2.Start client that sends HTTP requests and reads response in a loop 3.After some while headers on the server side will be messed up Expected Results: Headers should be parsed correctly: headers send by the client should be the same on the server side I've included server and client samples that can be used to reproduce the bug Server: class Program { static void Main(string[] args) { HttpListener httpLst = new HttpListener(); httpLst.Prefixes.Add("http://*:15555/test/"); httpLst.AuthenticationSchemes = AuthenticationSchemes.Anonymous | AuthenticationSchemes.None; httpLst.Start(); Thread th = new Thread( delegate() { try { HttpListenerContext lstCtx = null; while ((lstCtx = httpLst.GetContext()) != null) { Console.WriteLine("Begin request ======================"); foreach (string header in lstCtx.Request.Headers.AllKeys) { foreach (string val in lstCtx.Request.Headers.GetValues(header)) { Console.WriteLine(header + ": " + val); } } lstCtx.Response.StatusCode = 204; lstCtx.Response.Close(); Console.WriteLine("End request ========================"); Console.WriteLine(); } } catch (Exception ex) { Console.WriteLine(ex); } }); th.Start(); Console.ReadLine(); httpLst.Stop(); httpLst.Close(); } } Client: class Program { const char CR = '\r'; const char LF = '\n'; static void WriteHttpLineDelayed(string content, StreamWriter writer) { writer.Write(content); writer.Flush(); writer.Write(CR); writer.Flush(); writer.Write(LF); writer.Flush(); } static void Main(string[] args) { string address = "10.2.2.105"; int port = 15555; while (true) { TcpClient client = new TcpClient(); client.Connect(address, port); using (StreamWriter writer = new StreamWriter(client.GetStream())) { WriteHttpLineDelayed("GET /test/testme HTTP/1.0", writer); WriteHttpLineDelayed("User-Agent: Test", writer); WriteHttpLineDelayed("header1: value1,value2", writer); WriteHttpLineDelayed("header2: value1,value2", writer); WriteHttpLineDelayed("header3: value1,value2", writer); WriteHttpLineDelayed("header4: value1,value2", writer); WriteHttpLineDelayed("header5: value1", writer); WriteHttpLineDelayed("header6: value1", writer); WriteHttpLineDelayed("header7: value1", writer); WriteHttpLineDelayed("header8: value1", writer); WriteHttpLineDelayed(string.Format("Host: {0}:{1}", address, port), writer); writer.Write(CR); writer.Flush(); writer.Write(LF); writer.Flush(); StreamReader reader = new StreamReader(client.GetStream()); string response = reader.ReadLine(); } } } } -- 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. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
