2010-07-02 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 2 Jul 2010 16:10:21 +0000 (16:10 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 2 Jul 2010 16:10:21 +0000 (16:10 -0000)
* HttpStandaloneReplyChannel.cs, HttpStandaloneRequestContext.cs:
  add more code that the asp.net stuff will become like.

* SvcHttpHandlerFactory.cs : remove unused code.
* SvcHttpHandler.cs : ditto. Add some code for what new asp.net
  support will look like.

svn path=/trunk/mcs/; revision=159818

mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpStandaloneReplyChannel.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpStandaloneRequestContext.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandlerFactory.cs

index 2cc19661c4ce18bdcb58eea1b4f70ddee59fb508..5b798d7c81874cd3bc47231726867b9d6d6b756a 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpStandaloneReplyChannel.cs, HttpStandaloneRequestContext.cs:
+         add more code that the asp.net stuff will become like.
+
 2010-07-02  Atsushi Enomoto  <atsushi@ximian.com>
 
        * HttpStandaloneReplyChannel.cs, HttpListenerManager.cs,
index 7556c15850b98d31f082777b7a17904c2e6448d5..b21eebd3b10685267dc0d12fcf593e26091c3e38 100644 (file)
@@ -100,6 +100,29 @@ namespace System.ServiceModel.Channels.Http
                }
        }
 
+       internal class AspNetReplyChannel : HttpReplyChannel
+       {
+               public AspNetReplyChannel (HttpStandaloneChannelListener<IReplyChannel> listener)
+                       : base (listener)
+               {
+               }
+
+               protected override RequestContext CreateRequestContext (HttpContextInfo ctxi, Message msg)
+               {
+                       return new AspNetRequestContext (this, ctxi, msg);
+               }
+
+               protected override Message CreatePostMessage (HttpContextInfo ctxi)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool WaitForRequest (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
        internal abstract class HttpReplyChannel : InternalReplyChannelBase
        {
                HttpStandaloneChannelListener<IReplyChannel> source;
index 22a3f770a549b2ad5df7e811dadf84b456748819..d42cb3183fa1a59bb07eb8be7f83647d5e779c1e 100644 (file)
@@ -100,7 +100,7 @@ namespace System.ServiceModel.Channels.Http
 
        internal class AspNetRequestContext : HttpRequestContextBase
        {
-               public AspNetRequestContext (HttpReplyChannel channel, Message request)
+               public AspNetRequestContext (AspNetReplyChannel channel, HttpContextInfo ctxi, Message request)
                        : base (channel, request)
                {
                        throw new NotImplementedException ();
index 7d2256c575482cd85ed598bd0b32d03dab28a683..7ed8d39f6ff2eb5248ff949c19fb39e8ad8c2b94 100755 (executable)
@@ -1,3 +1,9 @@
+2010-07-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SvcHttpHandlerFactory.cs : remove unused code.
+       * SvcHttpHandler.cs : ditto. Add some code for what new asp.net
+         support will look like.
+
 2010-07-02  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Message.cs, MessageImpl.cs, MessageBufferImpl.cs : remove BodyId.
index 03031125372b513c0ecd27a58f8963f58616fa6d..0de3aae61a3e30b187933341d2e51f2b366ee257 100644 (file)
@@ -40,6 +40,7 @@ using System.ServiceModel.Description;
 
 namespace System.ServiceModel.Channels {
 
+#if !NEW_CODE
        internal class WcfListenerInfo
        {
                public WcfListenerInfo ()
@@ -60,6 +61,7 @@ namespace System.ServiceModel.Channels {
                        return info.Listener;
                }
        }
+#endif
 
        internal class SvcHttpHandler : IHttpHandler
        {
@@ -71,7 +73,9 @@ namespace System.ServiceModel.Channels {
                Type factory_type;
                string path;
                ServiceHostBase host;
+#if !NEW_CODE
                WcfListenerInfoCollection listeners = new WcfListenerInfoCollection ();
+#endif
                Dictionary<HttpContext,ManualResetEvent> wcf_wait_handles = new Dictionary<HttpContext,ManualResetEvent> ();
                int close_state;
 
@@ -91,6 +95,7 @@ namespace System.ServiceModel.Channels {
                        get { return host; }
                }
 
+#if !NEW_CODE
                public HttpContext WaitForRequest (IChannelListener listener)
                {
                        if (close_state > 0)
@@ -139,14 +144,27 @@ namespace System.ServiceModel.Channels {
                        if (best != null)
                                return best;
                        throw new InvalidOperationException (String.Format ("The argument HTTP context did not match any of the registered listener manager (could be mismatch in URL, method etc.) {0}", ctx.Request.Url));
-/*
-                       var actx = new AspNetHttpContextInfo (ctx);
-                       foreach (var i in listeners)
-                               if (i.Listener.GetProperty<HttpListenerManager> ().FilterHttpContext (actx))
-                                       return i.Listener;
-                       throw new InvalidOperationException ();
-*/
                }
+#endif
+
+#if NEW_CODE
+
+               public void ProcessRequest (HttpContext context)
+               {
+                       EnsureServiceHost ();
+
+                       var table = HttpListenerManagerTable.GetOrCreate (host);
+                       var manager = table.GetOrCreateManager (host.BaseAddresses [0]);
+                       var wait = new ManualResetEvent (false);
+                       wcf_wait_handles [context] = wait;
+                       manager.ProcessNewContext (new AspNetContextInfo (context));
+                       // This method must not return until the RequestContext
+                       // explicitly finishes replying. Otherwise xsp will
+                       // close the connection after this method call.
+                       wait.WaitOne ();
+               }
+
+#else
 
                public void ProcessRequest (HttpContext context)
                {
@@ -164,6 +182,7 @@ namespace System.ServiceModel.Channels {
 
                        wait.WaitOne ();
                }
+#endif
 
                public void EndRequest (IChannelListener listener, HttpContext context)
                {
@@ -183,6 +202,7 @@ namespace System.ServiceModel.Channels {
                        host = null;
                }
 
+#if !NEW_CODE
                public void RegisterListener (IChannelListener listener)
                {
                        lock (type_lock)
@@ -194,6 +214,8 @@ namespace System.ServiceModel.Channels {
                        listeners.Remove (listener);
                }
 
+#endif
+
                void EnsureServiceHost ()
                {
                        lock (type_lock) {
index 47776b192532a37750ccb0d6540d53232eed9276..e757f00eb98c874941c458030701079169da0884 100644 (file)
@@ -52,11 +52,6 @@ namespace System.ServiceModel.Channels {
                        ServiceHostingEnvironment.InAspNet = true;
                }
 
-               public static SvcHttpHandler GetHandlerForListener (IChannelListener listener)
-               {
-                       return handlers.Values.First (h => h.Host.ChannelDispatchers.Any (cd => cd.Listener == listener));
-               }
-
                public IHttpHandler GetHandler (HttpContext context, string requestType, string url, string pathTranslated)
                {
                        lock (handlers) {