New tests.
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Channels / HttpChannelListener.cs
index 371db63df8828cbee80d3618cda7fdc0d11ce1be..988d431c508e8402f8023c85f9eca6361bb680ee 100644 (file)
@@ -33,6 +33,7 @@ using System.Net;
 using System.Net.Security;
 using System.ServiceModel;
 using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
 using System.ServiceModel.Security;
 using System.Text;
 
@@ -66,7 +67,7 @@ namespace System.ServiceModel.Channels
 
                protected override HttpListenerManager CreateListenerManager ()
                {
-                       return new HttpSimpleListenerManager (this);
+                       return new HttpSimpleListenerManager (this, Source, SecurityTokenManager, ChannelDispatcher);
                }
        }
 
@@ -79,10 +80,6 @@ namespace System.ServiceModel.Channels
                {
                }
 
-               internal SvcHttpHandler HttpHandler {
-                       get { return ((AspNetListenerManager) ListenerManager).Source; }
-               }
-
                protected override TChannel CreateChannel (TimeSpan timeout)
                {
                        if (typeof (TChannel) == typeof (IReplyChannel))
@@ -93,23 +90,27 @@ namespace System.ServiceModel.Channels
 
                protected override HttpListenerManager CreateListenerManager ()
                {
-                       return new AspNetListenerManager (this);
+                       return new AspNetListenerManager (this, Source, SecurityTokenManager, ChannelDispatcher);
                }
        }
 
        internal abstract class HttpChannelListenerBase<TChannel> : InternalChannelListenerBase<TChannel>
                where TChannel : class, IChannel
        {
-               HttpTransportBindingElement source;
-               BindingContext context;
                List<TChannel> channels = new List<TChannel> ();
                MessageEncoder encoder;
                HttpListenerManager httpChannelManager;
 
+               internal static HttpChannelListenerBase<TChannel>CurrentHttpChannelListener;
+
                public HttpChannelListenerBase (HttpTransportBindingElement source,
                        BindingContext context)
                        : base (context)
                {
+                       if (ServiceHostBase.CurrentServiceHostHack != null)
+                               DispatcherBuilder.ChannelDispatcherSetter = delegate (ChannelDispatcher cd) { this.ChannelDispatcher = cd; };
+
+                       this.Source = source;
                        // The null Uri check looks weird, but it seems the listener can be built without it.
                        // See HttpTransportBindingElementTest.BuildChannelListenerWithoutListenUri().
                        if (Uri != null && source.Scheme != Uri.Scheme)
@@ -124,8 +125,15 @@ namespace System.ServiceModel.Channels
                        }
                        if (encoder == null)
                                encoder = new TextMessageEncoder (MessageVersion.Default, Encoding.UTF8);
+
+                       if (context.BindingParameters.Contains (typeof (ServiceCredentials)))
+                               SecurityTokenManager = new ServiceCredentialsSecurityTokenManager ((ServiceCredentials) context.BindingParameters [typeof (ServiceCredentials)]);
                }
 
+               internal ChannelDispatcher ChannelDispatcher { get; set; }
+
+               public HttpTransportBindingElement Source { get; private set; }
+
                public HttpListenerManager ListenerManager {
                        get {  return httpChannelManager; }
                }
@@ -134,6 +142,8 @@ namespace System.ServiceModel.Channels
                        get { return encoder; }
                }
 
+               public ServiceCredentialsSecurityTokenManager SecurityTokenManager { get; private set; }
+
                protected override TChannel OnAcceptChannel (TimeSpan timeout)
                {
                        TChannel ch = CreateChannel (timeout);