[Mono-bugs] [Bug 688860] New: Among HttpListeners that have overlapped prefixes, wrong HttpListener accepts requests when wildcard is used for each prefix

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Apr 20 12:40:42 EDT 2011


https://bugzilla.novell.com/show_bug.cgi?id=688860

https://bugzilla.novell.com/show_bug.cgi?id=688860#c0


           Summary: Among HttpListeners that have overlapped prefixes,
                    wrong HttpListener accepts requests when wildcard is
                    used for each prefix
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Windows 7
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: gonzalo at novell.com
        ReportedBy: aenomoto at novell.com
         QAContact: mono-bugs at lists.ximian.com
            Blocks: 687580
          Found By: ---
           Blocker: ---


This bug reproduces under similar condition to bug #688353, but with more
complicated server setup. The pair of repro replicates WCF AJAX integration
(WebScriptEnablingBehavior). It does these things:

- set up three HttpListeners, for http://*:8080/Foo/, http://*:8080/Foo/js/ and
http://*:8080/Foo/jsdebug.
- start each HttpListener and wait for request (BeginGetContext).
- Then let the client send a request to http://localhost:8080/Foo/jsdebug

The server should return http://*:8080/Foo/jsdebug/.

How to reproduce:
- compile client.cs and server.cs.
- run server.exe
- run client.exe
- see what is printed on client and/or server.

---- server.cs ----
using System;
using System.Collections.Generic;
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 (string [] args)
    {
        var prefixes = new string [] {
            "http://*:8080/Foo/",
            "http://*:8080/Foo/js/",
            "http://*:8080/Foo/jsdebug/"};
        var listeners = new List<HttpListener> ();
        foreach (var prefix_ in prefixes) {
            var prefix = args.Length > 0 ? prefix_.Replace ("*", args [0]) :
prefix_;
            var l = new HttpListener ();
            listeners.Add (l);
            l.Prefixes.Add (prefix);
            l.Start ();
            Console.WriteLine ("{0} - {1}", l.GetHashCode (), prefix);
            l.BeginGetContext (delegate (IAsyncResult result) {
                var ctx = l.EndGetContext (result);
                using (var sr = new StreamReader (ctx.Request.InputStream))
                    Console.WriteLine (sr.ReadToEnd ());
                ctx.Response.ContentType = "text/javascript; charset=utf-8";
                ctx.Response.ContentLength64 = prefix.Length;
                using (var tw = new StreamWriter (ctx.Response.OutputStream))
                    tw.Write (prefix);
                Console.WriteLine ("{0} - received {1}", l.GetHashCode (),
prefix);
                ctx.Response.Close ();
            }, null);
        }
        Console.ReadLine ();
        foreach (var l in listeners)
            l.Close ();
    }
}

---- client.cs ----
using System;
using System.IO;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Channels;

public class Test
{
    public static void Main ()
    {
        var hr = (HttpWebRequest) WebRequest.Create (new Uri
("http://localhost:8080/Foo/jsdebug"));
        hr.KeepAlive = false;
        hr.ContentType = "text/xml; charset=utf-8";
        hr.Headers ["SOAPAction"] = "\"urn:foo\"";
        var rr = new StreamReader (hr.GetResponse ().GetResponseStream ());
        Console.WriteLine (rr.ReadToEnd ());
        rr.Close ();
    }
}


Some notes:
- .NET returns "http://*:8080/Foo/jsdebug/" to client as expected. Mono
consistently returns "http://*:8080/Foo/" instead.
- This does not happen when the HTTP listener prefix does not come with "*". If
you pass "localhost" to the server executable, you'll see the server returns
the expected value. (It is because once we had a bug for this issue for
"without wildcard" case, and that was fixed.)

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list