X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.ServiceModel%2FSystem.ServiceModel.Channels.Http%2FHttpListenerManagerTable.cs;h=48a46ebf0b31a091fce3b79e2c4324c48d556829;hb=0a1e3ddf05121c7a43349babb5915db3eb1da4c6;hp=6c6a7e737664450a2c4d4bfd8b030e925da7ec34;hpb=10e67ce38fbee44b3f5584d4f9df6de6c5f4cc5c;p=mono.git diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpListenerManagerTable.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpListenerManagerTable.cs index 6c6a7e73766..48a46ebf0b3 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpListenerManagerTable.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpListenerManagerTable.cs @@ -70,16 +70,61 @@ namespace System.ServiceModel.Channels.Http public object ServiceHostKey { get; private set; } - public HttpListenerManager GetOrCreateManager (Uri uri) + public HttpListenerManager GetOrCreateManager (Uri uri, HttpTransportBindingElement element) { var m = listeners.FirstOrDefault (p => p.Key.Equals (uri)).Value; if (m == null) { - if (ServiceHostingEnvironment.InAspNet) - m = new AspNetHttpListenerManager (uri); - else - m = new HttpStandaloneListenerManager (uri); - listeners [uri] = m; + // Two special cases + string absolutePath = uri.AbsolutePath; + if (absolutePath.EndsWith ("/js", StringComparison.Ordinal) || + absolutePath.EndsWith ("/jsdebug", StringComparison.Ordinal)) + return CreateListenerManager (uri, element); + + // Try without the query, if any + UriBuilder ub = null; + if (!String.IsNullOrEmpty (uri.Query)) { + ub = new UriBuilder (uri); + ub.Query = null; + + m = listeners.FirstOrDefault (p => p.Key.Equals (ub.Uri)).Value; + if (m != null) + return m; + } + + // Chop off the part following the last / in the absolut path part + // of the Uri - this is the operation being called in, the remaining + // left-hand side of the absolute path should be the service + // endpoint address + if (ub == null) { + ub = new UriBuilder (uri); + ub.Query = null; + } + + int lastSlash = absolutePath.LastIndexOf ('/'); + if (lastSlash != -1) { + ub.Path = absolutePath.Substring (0, lastSlash); + m = listeners.FirstOrDefault (p => p.Key.Equals (ub.Uri)).Value; + if (m != null) + return m; + } } + + if (m == null) + return CreateListenerManager (uri, element); + + return m; + } + + HttpListenerManager CreateListenerManager (Uri uri, HttpTransportBindingElement element) + { + HttpListenerManager m; + + if (ServiceHostingEnvironment.InAspNet) + m = new AspNetHttpListenerManager (uri); + else + m = new HttpStandaloneListenerManager (uri, element); + listeners [uri] = m; + return m; } }