[Mono-bugs] [Bug 688353] New: HttpListener returns HTTP 400 when wildcard is used for host name and path exists
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Apr 19 02:32:54 EDT 2011
https://bugzilla.novell.com/show_bug.cgi?id=688353
https://bugzilla.novell.com/show_bug.cgi?id=688353#c0
Summary: HttpListener returns HTTP 400 when wildcard is used
for host name and path exists
Classification: Mono
Product: Mono: Class Libraries
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: aenomoto at novell.com
QAContact: mono-bugs at lists.ximian.com
Blocks: 687580
Found By: ---
Blocker: ---
The following HttpListener use case demonstrates that an HttpListener that is
given as a prefix that is a wildcard host name, suffixed with a subpath
(http://*:8080/foo). HTTP request to the server results in 400 (Bad Request).
Wildcard prefix with path does not result in failure, but this example is
reproducible.
---- server ----
using System;
using System.IO;
using System.Net;
using System.Threading;
using System.Xml;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
public class Test
{
public static void Main ()
{
for (int i = 0; i < 2; i++) {
var l = new HttpListener ();
l.Prefixes.Add ("http://*:8080/" + (i == 0 ? "foo/" : "bar/"));
l.Start ();
var ctx = l.GetContext ();
using (var sr = new StreamReader (ctx.Request.InputStream))
Console.WriteLine (sr.ReadToEnd ());
ctx.Response.Headers ["SOAPAction"] = "urn:foo";
ctx.Response.KeepAlive = false;
ctx.Response.ContentType = "text/xml; charset=utf-8";
ctx.Response.ContentLength64 = 86;
using (var tw = new StreamWriter (ctx.Response.OutputStream))
tw.Write ("<s:Envelope
xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body/></s:Envelope>");
ctx.Response.Close ();
l.Close ();
Thread.Sleep (1000); // This sleep is required (even on .NET) to
give some delay for something.
}
}
}
---- client ----
using System;
using System.IO;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Channels;
public class Test
{
public static void Main ()
{
for (int i = 0; i < 2; i++) {
var hr = (HttpWebRequest) WebRequest.Create (new Uri
("http://localhost:8080/" + (i == 0 ? "foo" : "bar")));
hr.Method = "POST";
hr.KeepAlive = false;
hr.ContentType = "text/xml; charset=utf-8";
hr.Headers ["SOAPAction"] = "\"urn:foo\"";
var rs = new StreamWriter (hr.GetRequestStream ());
rs.WriteLine (@"<s:Envelope
xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Header>
</s:Header>
<s:Body />
</s:Envelope>");
rs.Close ();
var rr = new StreamReader (hr.GetResponse ().GetResponseStream ());
Console.WriteLine (rr.ReadToEnd ());
rr.Close ();
}
}
}
On .NET, two requests and replies are processed as expected. On Mono, first
request fails.
Some notes:
- I (again) tried it on Windows, so it may work fine on other platforms.
- The repro kind of replicates WCF BasicHttpBinding; there's couple of
extraneous code I know.
- Actually the loop (i<2) doesn't matter. It fails at the first request.
- I set a blocker for bug #687580. That bug could be fixed by switching #if
false to #if true in System.ServiceModel.Channels.Http/HttpListenerManager.cs
line 113.
--
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