diff options
author | Egor Bogatov <egorbo@gmail.com> | 2018-06-25 12:15:20 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2018-06-25 12:15:20 +0300 |
commit | 51935465ae5935355206ceb49582e0352cc6229a (patch) | |
tree | cea8b67d252b4f29c5b501d58ada835f590f1d0b /mcs/class/System.ServiceModel | |
parent | 540f077c58cdd7883c6b0738a6b350f4ff62ca75 (diff) |
Delete unused files in BCL (#9288)
The following files in `mcs/class/*.cs` are not used anywhere (*.csproj/*.source).
Diffstat (limited to 'mcs/class/System.ServiceModel')
12 files changed, 0 insertions, 1528 deletions
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpHandler.cs deleted file mode 100644 index 66cbc6da883..00000000000 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpHandler.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// HttpHandler.cs -// -// Author: -// Igor Zelmanovich <igorz@mainsoft.com> -// -// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections.Generic; -using System.Text; -using System.Web; -using System.ServiceModel.Channels; - -namespace System.ServiceModel.Activation -{ - class HttpHandler : SvcHttpHandlerFactory - { - } -} diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpModule.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpModule.cs deleted file mode 100644 index 7cadbe76c96..00000000000 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpModule.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// BasicHttpBindingElementTest.cs -// -// Author: -// Igor Zelmanovich <igorz@mainsoft.com> -// -// Copyright (C) 2008 Mainsoft, Inc. http://www.mainsoft.com -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections.Generic; -using System.Text; -using System.Web; - -namespace System.ServiceModel.Activation -{ - class HttpModule : IHttpModule - { - #region IHttpModule Members - - public void Dispose () { - } - - public void Init (HttpApplication context) { - } - - #endregion - } -} diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationContextScopeHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationContextScopeHandler.cs deleted file mode 100644 index 768c4c19a9c..00000000000 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationContextScopeHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace System.ServiceModel.Dispatcher -{ - internal class OperationContextScopeHandler : BaseRequestProcessorHandler - { - public override void ProcessRequestChain (MessageProcessingContext mrc) - { - using (new OperationContextScope (mrc.OperationContext)) { - base.ProcessRequestChain (mrc); - } - } - - protected override bool ProcessRequest (MessageProcessingContext mrc) - { - return false; - } - } -} diff --git a/mcs/class/System.ServiceModel/fixup-config.cs b/mcs/class/System.ServiceModel/fixup-config.cs deleted file mode 100644 index d1ff541bf4f..00000000000 --- a/mcs/class/System.ServiceModel/fixup-config.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Xml; - -public class FixupXml -{ - public static void Main (string [] args) - { - if (args.Length == 0) { - Console.WriteLine ("pass path-to-machine.config."); - return; - } - XmlDocument doc = new XmlDocument (); - doc.Load (args [0]); - XmlElement el = doc.SelectSingleNode ("/configuration/configSections") as XmlElement; - XmlElement old = el.SelectSingleNode ("sectionGroup[@name='system.serviceModel']") as XmlElement; - XmlNode up = doc.ReadNode (new XmlTextReader ("fixup-config.xml")); - if (old != null) - el.RemoveChild (old); - el.InsertAfter (up, null); - XmlTextWriter w = new XmlTextWriter (args [0], null); - w.Formatting = Formatting.Indented; - w.IndentChar = '\t'; - w.Indentation = 1; - doc.Save (w); - w.Close (); - } -} - diff --git a/mcs/class/System.ServiceModel/fixup-config2.cs b/mcs/class/System.ServiceModel/fixup-config2.cs deleted file mode 100644 index 7aa4442b713..00000000000 --- a/mcs/class/System.ServiceModel/fixup-config2.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Xml; - -public class FixupXml -{ - public static void Main (string [] args) - { - if (args.Length == 0) { - Console.WriteLine ("pass path-to-web.config."); - return; - } - XmlDocument doc = new XmlDocument (); - doc.Load (args [0]); - XmlElement el = doc.SelectSingleNode ("/configuration/system.web/httpHandlers") as XmlElement; - XmlElement old = el.SelectSingleNode ("add[@path='*.svc']") as XmlElement; - XmlNode up = doc.ReadNode (new XmlTextReader ("fixup-config2.xml")); - if (old != null) - el.RemoveChild (old); - el.InsertAfter (up, null); - XmlTextWriter w = new XmlTextWriter (args [0], null); - w.Formatting = Formatting.Indented; - w.IndentChar = '\t'; - w.Indentation = 1; - doc.Save (w); - w.Close (); - } -} - diff --git a/mcs/class/System.ServiceModel/old-code/AspNetReplyChannel.cs b/mcs/class/System.ServiceModel/old-code/AspNetReplyChannel.cs deleted file mode 100644 index 572ef003348..00000000000 --- a/mcs/class/System.ServiceModel/old-code/AspNetReplyChannel.cs +++ /dev/null @@ -1,181 +0,0 @@ -// -// AspNetReplyChannel.cs -// -// Author: -// Ankit Jain <jankit@novell.com> -// -// Copyright (C) 2006 Novell, Inc. http://www.novell.com -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.ServiceModel; -using System.Text; -using System.Threading; -using System.Web; - -namespace System.ServiceModel.Channels -{ - internal class AspNetReplyChannel : HttpReplyChannel - { - AspNetChannelListener<IReplyChannel> listener; - List<HttpContext> waiting = new List<HttpContext> (); - HttpContext http_context; - ManualResetEvent wait; - - public AspNetReplyChannel (AspNetChannelListener<IReplyChannel> listener) - : base (listener) - { - this.listener = listener; - } - - internal void CloseContext () - { - if (http_context == null) - return; - try { - ((AspNetListenerManager) listener.ListenerManager).HttpHandler.EndRequest (listener, http_context); - } finally { - http_context = null; - } - } - - void ShutdownPendingRequests () - { - lock (waiting) - foreach (HttpContext ctx in waiting) - try { - ((AspNetListenerManager) listener.ListenerManager).HttpHandler.EndRequest (listener, ctx); - } catch { - } - } - - protected override void OnAbort () - { - ShutdownPendingRequests (); - CloseContext (); - } - - protected override void OnClose (TimeSpan timeout) - { - base.OnClose (timeout); - - ShutdownPendingRequests (); - CloseContext (); - } - - public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context) - { - try { - return TryReceiveRequestCore (timeout, out context); - } catch (Exception ex) { - // FIXME: log it - Console.WriteLine ("AspNetReplyChannel caught an error: " + ex); - throw; - } - } - - bool TryReceiveRequestCore (TimeSpan timeout, out RequestContext context) - { - context = null; - if (waiting.Count == 0 && !WaitForRequest (timeout)) - return false; - lock (waiting) { - if (waiting.Count > 0) { - http_context = waiting [0]; - waiting.RemoveAt (0); - } - } - if (http_context == null) - // Though as long as this instance is used - // synchronously, it should not happen. - return false; - if (http_context.Response.StatusCode != 200) { - http_context.Response.Close (); - return false; - } - - Message msg; - var req = http_context.Request; - if (req.HttpMethod == "GET") { - msg = Message.CreateMessage (Encoder.MessageVersion, null); - } else { - //FIXME: Do above stuff for HttpContext ? - int maxSizeOfHeaders = 0x10000; - - msg = Encoder.ReadMessage ( - req.InputStream, maxSizeOfHeaders); - - if (Encoder.MessageVersion.Envelope == EnvelopeVersion.Soap11) { - string action = GetHeaderItem (req.Headers ["SOAPAction"]); - if (action != null) - msg.Headers.Action = action; - } - } - - // FIXME: prop.SuppressEntityBody - msg.Headers.To = req.Url; - msg.Properties.Add ("Via", LocalAddress.Uri); - msg.Properties.Add (HttpRequestMessageProperty.Name, CreateRequestProperty (req.HttpMethod, req.Url.Query, req.Headers)); - - context = new AspNetRequestContext (this, msg, http_context); - - return true; - } - - /* - public override bool WaitForRequest (TimeSpan timeout) - { - if (http_context == null) - http_context = listener.HttpHandler.WaitForRequest (listener, timeout); - return http_context != null; - } - */ - - public override bool WaitForRequest (TimeSpan timeout) - { - if (wait != null) - throw new InvalidOperationException ("Another wait operation is in progress"); - try { - var wait_ = new ManualResetEvent (false); - wait = wait_; - listener.ListenerManager.GetHttpContextAsync (timeout, HttpContextAcquired); - return wait_.WaitOne (timeout, false) && waiting.Count > 0; - } finally { - wait = null; - } - } - - void HttpContextAcquired (HttpContextInfo ctx) - { - if (wait == null) - throw new InvalidOperationException ("WaitForRequest operation has not started"); - var sctx = (AspNetHttpContextInfo) ctx; - if (State == CommunicationState.Opened && ctx != null) - waiting.Add (sctx.Source); - var wait_ = wait; - wait = null; - wait_.Set (); - } - } -} diff --git a/mcs/class/System.ServiceModel/old-code/AspNetRequestContext.cs b/mcs/class/System.ServiceModel/old-code/AspNetRequestContext.cs deleted file mode 100644 index 59bf2bbcbca..00000000000 --- a/mcs/class/System.ServiceModel/old-code/AspNetRequestContext.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// AspNetRequestContext.cs -// -// Author: -// Ankit Jain <jankit@novell.com> -// -// Copyright (C) 2006 Novell, Inc. http://www.novell.com -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Globalization; -using System.IO; -using System.Net; -using System.Web; - -namespace System.ServiceModel.Channels { - - class AspNetRequestContext : HttpRequestContextBase - { - AspNetReplyChannel channel; - HttpContext ctx; - - public AspNetRequestContext ( - AspNetReplyChannel channel, - Message msg, HttpContext ctx) - : base (channel, msg) - { - this.channel = channel; - this.ctx = ctx; - } - - public override void Abort () - { - //ctx.Response.Abort (); - ctx = null; - channel.CloseContext (); - } - - protected override void ProcessReply (Message msg, TimeSpan timeout) - { - ctx.Response.ContentType = Channel.Encoder.ContentType; - MemoryStream ms = new MemoryStream (); - Channel.Encoder.WriteMessage (msg, ms); - - string pname = HttpResponseMessageProperty.Name; - bool suppressEntityBody = false; - if (msg.Properties.ContainsKey (pname)) { - HttpResponseMessageProperty hp = (HttpResponseMessageProperty) msg.Properties [pname]; - string contentType = hp.Headers ["Content-Type"]; - if (contentType != null) - ctx.Response.ContentType = contentType; - ctx.Response.Headers.Add (hp.Headers); - if (hp.StatusCode != default (HttpStatusCode)) - ctx.Response.StatusCode = (int) hp.StatusCode; - ctx.Response.StatusDescription = hp.StatusDescription; - if (hp.SuppressEntityBody) - suppressEntityBody = true; - } - if (msg.IsFault) - ctx.Response.StatusCode = 500; - if (!suppressEntityBody) { - ctx.Response.AddHeader ("Content-Length", ms.Length.ToString (CultureInfo.InvariantCulture)); - ctx.Response.OutputStream.Write (ms.GetBuffer (), 0, (int) ms.Length); - ctx.Response.OutputStream.Flush (); - } - else - ctx.Response.SuppressContent = true; - } - - public override void Close (TimeSpan timeout) - { - ctx = null; - channel.CloseContext (); - } - } -} diff --git a/mcs/class/System.ServiceModel/old-code/HttpChannelListener.cs b/mcs/class/System.ServiceModel/old-code/HttpChannelListener.cs deleted file mode 100644 index 9574291c43d..00000000000 --- a/mcs/class/System.ServiceModel/old-code/HttpChannelListener.cs +++ /dev/null @@ -1,199 +0,0 @@ -// -// HttpChannelListener.cs -// -// Author: -// Atsushi Enomoto <atsushi@ximian.com> -// -// Copyright (C) 2005 Novell, Inc. http://www.novell.com -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -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; -using System.Threading; - -namespace System.ServiceModel.Channels -{ - internal class HttpSimpleChannelListener<TChannel> : HttpChannelListenerBase<TChannel> - where TChannel : class, IChannel - { - public HttpSimpleChannelListener (HttpTransportBindingElement source, - BindingContext context) - : base (source, context) - { - } - - protected override TChannel CreateChannel (TimeSpan timeout) - { - lock (ThisLock) { - return CreateChannelCore (timeout); - } - } - - TChannel CreateChannelCore (TimeSpan timeout) - { - if (typeof (TChannel) == typeof (IReplyChannel)) - return (TChannel) (object) new HttpSimpleReplyChannel ((HttpSimpleChannelListener<IReplyChannel>) (object) this); - - throw new NotSupportedException (String.Format ("Channel type {0} is not supported", typeof (TChannel))); - } - - protected override HttpListenerManager CreateListenerManager () - { - return new HttpSimpleListenerManager (this, Source, SecurityTokenManager, ChannelDispatcher); - } - } - - internal class AspNetChannelListener<TChannel> : HttpChannelListenerBase<TChannel> - where TChannel : class, IChannel - { - public AspNetChannelListener (HttpTransportBindingElement source, - BindingContext context) - : base (source, context) - { - } - - protected override TChannel CreateChannel (TimeSpan timeout) - { - if (typeof (TChannel) == typeof (IReplyChannel)) - return (TChannel) (object) new AspNetReplyChannel ((AspNetChannelListener<IReplyChannel>) (object) this); - - throw new NotSupportedException (String.Format ("Channel type {0} is not supported", typeof (TChannel))); - } - - protected override HttpListenerManager CreateListenerManager () - { - return new AspNetListenerManager (this, Source, SecurityTokenManager, ChannelDispatcher); - } - } - - internal interface IChannelDispatcherBoundListener - { - ChannelDispatcher ChannelDispatcher { get; set; } - } - - internal abstract class HttpChannelListenerBase<TChannel> : InternalChannelListenerBase<TChannel>, IChannelDispatcherBoundListener - where TChannel : class, IChannel - { - HttpListenerManager httpChannelManager; - - 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) - throw new ArgumentException (String.Format ("Requested listen uri scheme must be {0}, but was {1}.", source.Scheme, Uri.Scheme)); - - foreach (BindingElement be in context.Binding.Elements) { - MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement; - if (mbe != null) { - MessageEncoder = CreateEncoder<TChannel> (mbe); - break; - } - } - if (MessageEncoder == null) - MessageEncoder = new TextMessageEncoder (MessageVersion.Default, Encoding.UTF8); - - if (context.BindingParameters.Contains (typeof (ServiceCredentials))) - SecurityTokenManager = new ServiceCredentialsSecurityTokenManager ((ServiceCredentials) context.BindingParameters [typeof (ServiceCredentials)]); - } - - public ChannelDispatcher ChannelDispatcher { get; set; } - - public HttpTransportBindingElement Source { get; private set; } - - public HttpListenerManager ListenerManager { - get { return httpChannelManager; } - } - - public ServiceCredentialsSecurityTokenManager SecurityTokenManager { get; private set; } - - ManualResetEvent accept_channel_handle = new ManualResetEvent (true); - - protected override TChannel OnAcceptChannel (TimeSpan timeout) - { - // HTTP channel listeners do not accept more than one channel at a time. - DateTime start = DateTime.UtcNow; - accept_channel_handle.WaitOne (timeout - (DateTime.UtcNow - start)); - accept_channel_handle.Reset (); - TChannel ch = CreateChannel (timeout - (DateTime.UtcNow - start)); - ch.Closed += delegate { - accept_channel_handle.Set (); - }; - return ch; - } - - protected abstract TChannel CreateChannel (TimeSpan timeout); - - protected override bool OnWaitForChannel (TimeSpan timeout) - { - throw new NotImplementedException (); - } - - protected abstract HttpListenerManager CreateListenerManager (); - - protected override void OnOpen (TimeSpan timeout) - { - httpChannelManager = CreateListenerManager (); - Properties.Add (httpChannelManager); - httpChannelManager.Open (timeout); - } - - protected override void OnAbort () - { - httpChannelManager.Stop (true); - } - - protected override void OnClose (TimeSpan timeout) - { - if (State == CommunicationState.Closed) - return; - base.OnClose (timeout); - // The channels are kept open when the creator channel listener is closed. - // http://blogs.msdn.com/drnick/archive/2006/03/22/557642.aspx - httpChannelManager.Stop (false); - } - - // immediately stop accepting channel. - public override bool CancelAsync (TimeSpan timeout) - { - try { - CurrentAsyncResult.AsyncWaitHandle.WaitOne (TimeSpan.Zero); - } catch (TimeoutException) { - } - return true; - } - } -} diff --git a/mcs/class/System.ServiceModel/old-code/HttpListenerManager.cs b/mcs/class/System.ServiceModel/old-code/HttpListenerManager.cs deleted file mode 100644 index ef149bc4ad4..00000000000 --- a/mcs/class/System.ServiceModel/old-code/HttpListenerManager.cs +++ /dev/null @@ -1,411 +0,0 @@ -// -// HttpListenerManager.cs -// -// Author: -// Vladimir Krasnov <vladimirk@mainsoft.com> -// Atsushi Enomoto <atsushi@ximian.com> -// -// Copyright (C) 2005-2006 Mainsoft, Inc. http://www.mainsoft.com -// Copyright (C) 2009-2010 Novell, Inc. http://www.novell.com -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.IdentityModel.Selectors; -using System.IdentityModel.Tokens; -using System.ServiceModel.Description; -using System.ServiceModel.Dispatcher; -using System.ServiceModel.Security; -using System.Security.Principal; -using System.Text; -using System.Threading; -using System.Net; -using System.Web; - -namespace System.ServiceModel.Channels -{ - abstract class HttpContextInfo - { - public abstract NameValueCollection QueryString { get; } - public abstract Uri RequestUrl { get; } - public abstract string HttpMethod { get; } - public abstract void Abort (); - - public abstract string User { get; } - public abstract string Password { get; } - public abstract void ReturnUnauthorized (); - } - - class HttpListenerContextInfo : HttpContextInfo - { - public HttpListenerContextInfo (HttpListenerContext ctx) - { - this.ctx = ctx; - } - - HttpListenerContext ctx; - - public HttpListenerContext Source { - get { return ctx; } - } - - public override NameValueCollection QueryString { - get { return ctx.Request.QueryString; } - } - public override Uri RequestUrl { - get { return ctx.Request.Url; } - } - public override string HttpMethod { - get { return ctx.Request.HttpMethod; } - } - public override void Abort () - { - ctx.Response.Abort (); - } - - public override string User { - get { return ctx.User != null ? ((HttpListenerBasicIdentity) ctx.User.Identity).Name : null; } - } - - public override string Password { - get { return ctx.User != null ? ((HttpListenerBasicIdentity) ctx.User.Identity).Password : null; } - } - - public override void ReturnUnauthorized () - { - ctx.Response.StatusCode = 401; - } - } - - class AspNetHttpContextInfo : HttpContextInfo - { - public AspNetHttpContextInfo (HttpContext ctx) - { - this.ctx = ctx; - } - - HttpContext ctx; - - public HttpContext Source { - get { return ctx; } - } - - public override NameValueCollection QueryString { - get { return ctx.Request.QueryString; } - } - public override Uri RequestUrl { - get { return ctx.Request.Url; } - } - public override string HttpMethod { - get { return ctx.Request.HttpMethod; } - } - - public override void Abort () - { - ctx.Response.Close (); - } - - public override string User { - get { return ctx.User != null ? ((GenericIdentity) ctx.User.Identity).Name : null; } - } - - // FIXME: how to acquire this? - public override string Password { - get { return null; } - } - - public override void ReturnUnauthorized () - { - ctx.Response.StatusCode = 401; - } - } - - internal class HttpSimpleListenerManager : HttpListenerManager - { - static Dictionary<object,Dictionary<Uri,HttpListener>> http_listeners_table = new Dictionary<object,Dictionary<Uri,HttpListener>> (); - - Dictionary<Uri, HttpListener> opened_listeners; - HttpListener http_listener; - - public HttpSimpleListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ChannelDispatcher dispatcher) - : base (channelListener, source, securityTokenManager, dispatcher) - { - object key = dispatcher != null ? dispatcher.Host : new object (); // so that HttpChannelListener without ServiceHost is always assigned a new table. - if (!http_listeners_table.TryGetValue (key, out opened_listeners)) { - opened_listeners = new Dictionary<Uri, HttpListener> (); - http_listeners_table [key] = opened_listeners; - } - } - - protected override void OnRegister (IChannelListener channelListener, TimeSpan timeout) - { - lock (opened_listeners) { - if (!opened_listeners.ContainsKey (channelListener.Uri)) { - HttpListener listener = new HttpListener (); - listener.AuthenticationSchemeSelectorDelegate = delegate (HttpListenerRequest req) { - return Source.AuthenticationScheme; - }; - listener.Realm = Source.Realm; - listener.UnsafeConnectionNtlmAuthentication = Source.UnsafeConnectionNtlmAuthentication; - - string uriString = channelListener.Uri.ToString (); - if (!uriString.EndsWith ("/", StringComparison.Ordinal)) - uriString += "/"; - listener.Prefixes.Add (uriString); - listener.Start (); - - opened_listeners [channelListener.Uri] = listener; - } - - http_listener = opened_listeners [channelListener.Uri]; - } - } - - protected override void OnUnregister (IChannelListener listener, bool abort) - { - lock (opened_listeners) { - if (http_listener == null) - return; - if (http_listener.IsListening) { - if (abort) - http_listener.Abort (); - else - http_listener.Close (); - } - ((IDisposable) http_listener).Dispose (); - - opened_listeners.Remove (listener.Uri); - } - - http_listener = null; - } - - protected override void KickContextReceiver (IChannelListener listener, Action<HttpContextInfo> contextReceivedCallback) - { - http_listener.BeginGetContext (delegate (IAsyncResult result) { - var hctx = http_listener.EndGetContext (result); - contextReceivedCallback (new HttpListenerContextInfo (hctx)); - }, null); - } - } - - internal class AspNetListenerManager : HttpListenerManager - { - SvcHttpHandler http_handler; - - public AspNetListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ChannelDispatcher dispatcher) - : base (channelListener, source, securityTokenManager, dispatcher) - { - http_handler = SvcHttpHandler.Current; - } - - internal SvcHttpHandler HttpHandler { get { return http_handler; } } - - protected override void OnRegister (IChannelListener channelListener, TimeSpan timeout) - { - http_handler.RegisterListener (channelListener); - } - - protected override void OnUnregister (IChannelListener listener, bool abort) - { - http_handler.UnregisterListener (listener); - } - - Func<IChannelListener,HttpContext> wait_delegate; - - protected override void KickContextReceiver (IChannelListener listener, Action<HttpContextInfo> contextReceivedCallback) - { - if (wait_delegate == null) - wait_delegate = new Func<IChannelListener,HttpContext> (http_handler.WaitForRequest); -// FIXME: Remove this workaround. This Func<>.BeginInvoke() invocation -// somehow fails and does not kick this method asynchronously. -#if false - wait_delegate.BeginInvoke (listener, delegate (IAsyncResult result) { - var ctx = wait_delegate.EndInvoke (result); - contextReceivedCallback (ctx != null ? new AspNetHttpContextInfo (ctx) : null); - }, null); -#else - var ctx = wait_delegate.Invoke (listener); - contextReceivedCallback (ctx != null ? new AspNetHttpContextInfo (ctx) : null); -#endif - } - } - - internal abstract class HttpListenerManager - { - static Dictionary<Uri, List<IChannelListener>> registered_channels; - IChannelListener channel_listener; - ManualResetEvent wait_http_ctx = new ManualResetEvent (false); - List<HttpContextInfo> pending = new List<HttpContextInfo> (); - - public HttpTransportBindingElement Source { get; private set; } - public ChannelDispatcher Dispatcher { get; private set; } - - SecurityTokenAuthenticator security_token_authenticator; - SecurityTokenResolver security_token_resolver; - - static HttpListenerManager () - { - registered_channels = new Dictionary<Uri, List<IChannelListener>> (); - } - - protected HttpListenerManager (IChannelListener channelListener, HttpTransportBindingElement source, ServiceCredentialsSecurityTokenManager securityTokenManager, ChannelDispatcher dispatcher) - { - this.Dispatcher = dispatcher; - this.channel_listener = channelListener; - Source = source; - - if (securityTokenManager != null) { - var str = new SecurityTokenRequirement () { TokenType = SecurityTokenTypes.UserName }; - security_token_authenticator = securityTokenManager.CreateSecurityTokenAuthenticator (str, out security_token_resolver); - } - } - - public void Open (TimeSpan timeout) - { - if (!registered_channels.ContainsKey (channel_listener.Uri)) - registered_channels [channel_listener.Uri] = new List<IChannelListener> (); - OnRegister (channel_listener, timeout); - registered_channels [channel_listener.Uri].Add (channel_listener); - } - - public void Stop (bool abort) - { - List<IChannelListener> channelsList = registered_channels [channel_listener.Uri]; - channelsList.Remove (channel_listener); - - try { - foreach (var ctx in pending) - ctx.Abort (); - } catch (Exception ex) { - // FIXME: log it - Console.WriteLine ("error during HTTP channel listener shutdown: " + ex); - } - - if (channelsList.Count == 0) - OnUnregister (channel_listener, abort); - } - - protected abstract void OnRegister (IChannelListener listener, TimeSpan timeout); - protected abstract void OnUnregister (IChannelListener listener, bool abort); - - public void CancelGetHttpContextAsync () - { - wait_http_ctx.Set (); - } - - // Do not directly handle retrieved HttpListenerContexts when - // the listener received ones. - // Instead, iterate every listeners to find the most-likely- - // matching one and immediately handle the listener context. - // If the listener is not requesting a context right now, then - // store it in *each* listener's queue. - - public void GetHttpContextAsync (TimeSpan timeout, Action<HttpContextInfo> callback) - { - lock (pending) { - foreach (var pctx in pending) { - if (FilterHttpContext (pctx)) { - pending.Remove (pctx); - callback (pctx); - return; - } - } - } - KickContextReceiver (channel_listener, DispatchHttpListenerContext); - wait_http_ctx.WaitOne (timeout); - wait_http_ctx.Reset (); - lock (pending) { - HttpContextInfo ctx = pending.Count > 0 ? pending [0] : null; - if (ctx != null) - pending.Remove (ctx); - callback (ctx); - } - } - - protected abstract void KickContextReceiver (IChannelListener listener, Action<HttpContextInfo> contextReceiverCallback); - - void DispatchHttpListenerContext (HttpContextInfo ctx) - { - foreach (var l in registered_channels [channel_listener.Uri]) { - var lm = l.GetProperty<HttpListenerManager> (); - if (lm.FilterHttpContext (ctx)) { - lm.AddListenerContext (ctx); - return; - } - } - AddListenerContext (ctx); - } - - void AddListenerContext (HttpContextInfo ctx) - { - if (Source.AuthenticationScheme != AuthenticationSchemes.Anonymous) { - if (security_token_authenticator != null) - // FIXME: use return value? - try { - security_token_authenticator.ValidateToken (new UserNameSecurityToken (ctx.User, ctx.Password)); - } catch (Exception) { - ctx.ReturnUnauthorized (); - } - else { - ctx.ReturnUnauthorized (); - } - } - - lock (pending) { - pending.Add (ctx); - // FIXME: this should not be required, but it somehow saves some failures wrt concurrent calls. - Thread.Sleep (100); - wait_http_ctx.Set (); - } - } - - const UriComponents cmpflag = UriComponents.HttpRequestUrl ^ UriComponents.Query; - const UriFormat fmtflag = UriFormat.SafeUnescaped; - - internal bool FilterHttpContext (HttpContextInfo ctx) - { - if (Dispatcher == null) - return true; // no mex can be involved. - if (ctx.HttpMethod.ToUpper () != "GET") - return !Dispatcher.IsMex; // non-GET request never matches mex channel dispatcher. - var sme = Dispatcher.Host.Extensions.Find<ServiceMetadataExtension> (); - if (sme == null) - return true; // no mex can be involved. - - var listener = Dispatcher.Listener; - var mex = sme.Instance; - - // now the request is GET, and we have to return true or false based on the matrix below: - // matches wsdl or help| yes | no | - // mex | yes | no | yes | no | - // --------------------+-----+----+-----+----+ - // | T | F | F | T | - - bool match = - (mex.WsdlUrl != null && Uri.Compare (ctx.RequestUrl, mex.WsdlUrl, cmpflag, fmtflag, StringComparison.Ordinal) == 0) || - (mex.HelpUrl != null && Uri.Compare (ctx.RequestUrl, mex.HelpUrl, cmpflag, fmtflag, StringComparison.Ordinal) == 0); - - return !(match ^ Dispatcher.IsMex); - } - } -} diff --git a/mcs/class/System.ServiceModel/old-code/HttpReplyChannel.cs b/mcs/class/System.ServiceModel/old-code/HttpReplyChannel.cs deleted file mode 100644 index a8b28c3ebea..00000000000 --- a/mcs/class/System.ServiceModel/old-code/HttpReplyChannel.cs +++ /dev/null @@ -1,252 +0,0 @@ -// -// HttpReplyChannel.cs -// -// Author: -// Atsushi Enomoto <atsushi@ximian.com> -// -// Copyright (C) 2006 Novell, Inc. http://www.novell.com -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.IO; -using System.Net; -using System.ServiceModel; -using System.Text; -using System.Threading; - -namespace System.ServiceModel.Channels -{ - internal class HttpSimpleReplyChannel : HttpReplyChannel - { - HttpSimpleChannelListener<IReplyChannel> source; - List<HttpListenerContext> waiting = new List<HttpListenerContext> (); - RequestContext reqctx; - - public HttpSimpleReplyChannel (HttpSimpleChannelListener<IReplyChannel> listener) - : base (listener) - { - this.source = listener; - } - - protected override void OnAbort () - { - AbortConnections (TimeSpan.Zero); - base.OnAbort (); // FIXME: remove it. The base is wrong. But it is somehow required to not block some tests. - } - - public override bool CancelAsync (TimeSpan timeout) - { - AbortConnections (timeout); - // FIXME: this wait is sort of hack (because it should not be required), but without it some tests are blocked. - // This hack even had better be moved to base.CancelAsync(). - if (CurrentAsyncResult != null) - CurrentAsyncResult.AsyncWaitHandle.WaitOne (TimeSpan.FromMilliseconds (300)); - return base.CancelAsync (timeout); - } - - void SignalAsyncWait () - { - if (wait == null) - return; - var wait_ = wait; - wait = null; - wait_.Set (); - } - - void AbortConnections (TimeSpan timeout) - { - // FIXME: use timeout - lock (waiting) - foreach (var ctx in waiting) - ctx.Response.Close (); - if (wait != null) - source.ListenerManager.CancelGetHttpContextAsync (); - } - - protected override void OnClose (TimeSpan timeout) - { - DateTime start = DateTime.UtcNow; - if (reqctx != null) - reqctx.Close (timeout); - - // FIXME: consider timeout - AbortConnections (timeout - (DateTime.UtcNow - start)); - - base.OnClose (timeout - (DateTime.UtcNow - start)); - } - - public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context) - { - context = null; - if (waiting.Count == 0 && !WaitForRequest (timeout)) - return false; - HttpListenerContext ctx = null; - lock (waiting) { - if (waiting.Count > 0) { - ctx = waiting [0]; - waiting.RemoveAt (0); - } - } - if (ctx == null) - // Though as long as this instance is used - // synchronously, it should not happen. - return false; - if (ctx.Response.StatusCode != 200) { - ctx.Response.Close (); - return false; - } - - // FIXME: supply maxSizeOfHeaders. - int maxSizeOfHeaders = 0x10000; - - Message msg = null; - - if (ctx.Request.HttpMethod == "POST") { - if (!Encoder.IsContentTypeSupported (ctx.Request.ContentType)) { - ctx.Response.StatusCode = (int) HttpStatusCode.UnsupportedMediaType; - ctx.Response.StatusDescription = String.Format ( - "Expected content-type '{0}' but got '{1}'", Encoder.ContentType, ctx.Request.ContentType); - ctx.Response.Close (); - - return false; - } - - msg = Encoder.ReadMessage ( - ctx.Request.InputStream, maxSizeOfHeaders); - - if (MessageVersion.Envelope.Equals (EnvelopeVersion.Soap11) || - MessageVersion.Addressing.Equals (AddressingVersion.None)) { - string action = GetHeaderItem (ctx.Request.Headers ["SOAPAction"]); - if (action != null) { - if (action.Length > 2 && action [0] == '"' && action [action.Length] == '"') - action = action.Substring (1, action.Length - 2); - msg.Headers.Action = action; - } - } - } else if (ctx.Request.HttpMethod == "GET") { - msg = Message.CreateMessage (MessageVersion.None, null); - } - if (msg.Headers.To == null) - msg.Headers.To = ctx.Request.Url; - msg.Properties.Add ("Via", LocalAddress.Uri); - msg.Properties.Add (HttpRequestMessageProperty.Name, CreateRequestProperty (ctx.Request.HttpMethod, ctx.Request.Url.Query, ctx.Request.Headers)); -/* -MessageBuffer buf = msg.CreateBufferedCopy (0x10000); -msg = buf.CreateMessage (); -Console.WriteLine (buf.CreateMessage ()); -*/ - context = new HttpRequestContext (this, msg, ctx); - reqctx = context; - return true; - } - - ManualResetEvent wait; - - public override bool WaitForRequest (TimeSpan timeout) - { - if (wait != null) - throw new InvalidOperationException ("Another wait operation is in progress"); - try { - var wait_ = new ManualResetEvent (false); - wait = wait_; // wait can be set to null if HttpContextAcquired runs to completion before we do WaitOne - source.ListenerManager.GetHttpContextAsync (timeout, HttpContextAcquired); - return wait_.WaitOne (timeout, false) && waiting.Count > 0; - } catch (HttpListenerException e) { - // FIXME: does this make sense? I doubt. - if ((uint) e.ErrorCode == 0x80004005) // invalid handle. Happens during shutdown. - while (true) Thread.Sleep (1000); // thread is about to be terminated. - throw; - } catch (ObjectDisposedException) { - return false; - } finally { - wait = null; - } - } - - void HttpContextAcquired (HttpContextInfo ctx) - { - if (wait == null) - throw new InvalidOperationException ("WaitForRequest operation has not started"); - var sctx = (HttpListenerContextInfo) ctx; - if (State == CommunicationState.Opened && ctx != null) - lock (waiting) - waiting.Add (sctx.Source); - SignalAsyncWait (); - } - } - - internal abstract class HttpReplyChannel : InternalReplyChannelBase - { - HttpChannelListenerBase<IReplyChannel> source; - - public HttpReplyChannel (HttpChannelListenerBase<IReplyChannel> listener) - : base (listener) - { - this.source = listener; - } - - public MessageEncoder Encoder { - get { return source.MessageEncoder; } - } - - internal MessageVersion MessageVersion { - get { return source.MessageEncoder.MessageVersion; } - } - - public override RequestContext ReceiveRequest (TimeSpan timeout) - { - RequestContext ctx; - TryReceiveRequest (timeout, out ctx); - return ctx; - } - - protected override void OnOpen (TimeSpan timeout) - { - } - - protected string GetHeaderItem (string raw) - { - if (raw == null || raw.Length == 0) - return raw; - switch (raw [0]) { - case '\'': - case '"': - if (raw [raw.Length - 1] == raw [0]) - return raw.Substring (1, raw.Length - 2); - // FIXME: is it simply an error? - break; - } - return raw; - } - - protected HttpRequestMessageProperty CreateRequestProperty (string method, string query, NameValueCollection headers) - { - var prop = new HttpRequestMessageProperty (); - prop.Method = method; - prop.QueryString = query.StartsWith ("?") ? query.Substring (1) : query; - // FIXME: prop.SuppressEntityBody - prop.Headers.Add (headers); - return prop; - } - } -} diff --git a/mcs/class/System.ServiceModel/old-code/HttpRequestContext.cs b/mcs/class/System.ServiceModel/old-code/HttpRequestContext.cs deleted file mode 100644 index 9a4415919d5..00000000000 --- a/mcs/class/System.ServiceModel/old-code/HttpRequestContext.cs +++ /dev/null @@ -1,173 +0,0 @@ -// -// HttpRequestContext.cs -// -// Author: -// Atsushi Enomoto <atsushi@ximian.com> -// -// Copyright (C) 2006 Novell, Inc. http://www.novell.com -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.IO; -using System.Net; -using System.Threading; - -namespace System.ServiceModel.Channels -{ - internal class HttpRequestContext : HttpRequestContextBase - { - HttpListenerContext ctx; - - public HttpRequestContext ( - HttpReplyChannel channel, - Message msg, HttpListenerContext ctx) - : base (channel, msg) - { - if (ctx == null) - throw new ArgumentNullException ("ctx"); - this.ctx = ctx; - } - - public override void Abort () - { - ctx.Response.Abort (); - } - - protected override void ProcessReply (Message msg, TimeSpan timeout) - { - if (msg == null) - throw new ArgumentNullException ("msg"); - - // FIXME: probably in WebHttpBinding land, there should - // be some additional code (probably IErrorHandler) that - // treats DestinationUnreachable (and possibly any other) - // errors as HTTP 400 or something appropriate. - // I originally rewrote the HTTP status here, but it - // was wrong. - - // FIXME: should this be done here? - if (Channel.MessageVersion.Addressing.Equals (AddressingVersion.None)) - msg.Headers.Action = null; // prohibited - - MemoryStream ms = new MemoryStream (); - Channel.Encoder.WriteMessage (msg, ms); - ctx.Response.ContentType = Channel.Encoder.ContentType; - - string pname = HttpResponseMessageProperty.Name; - bool suppressEntityBody = false; - if (msg.Properties.ContainsKey (pname)) { - HttpResponseMessageProperty hp = (HttpResponseMessageProperty) msg.Properties [pname]; - string contentType = hp.Headers ["Content-Type"]; - if (contentType != null) - ctx.Response.ContentType = contentType; - ctx.Response.Headers.Add (hp.Headers); - if (hp.StatusCode != default (HttpStatusCode)) - ctx.Response.StatusCode = (int) hp.StatusCode; - ctx.Response.StatusDescription = hp.StatusDescription; - if (hp.SuppressEntityBody) - suppressEntityBody = true; - } - if (msg.IsFault) - ctx.Response.StatusCode = 500; - if (!suppressEntityBody) { - ctx.Response.ContentLength64 = ms.Length; - ctx.Response.OutputStream.Write (ms.GetBuffer (), 0, (int) ms.Length); - ctx.Response.OutputStream.Flush (); - } - } - - public override void Close (TimeSpan timeout) - { - ctx.Response.Close (); - } - } - - internal abstract class HttpRequestContextBase : RequestContext - { - Message request; - HttpReplyChannel channel; - - public HttpRequestContextBase ( - HttpReplyChannel channel, - Message request) - { - if (channel == null) - throw new ArgumentNullException ("channel"); - if (request == null) - throw new ArgumentNullException ("request"); - this.channel = channel; - this.request = request; - } - - public override Message RequestMessage { - get { return request; } - } - - public HttpReplyChannel Channel { - get { return channel; } - } - - protected abstract void ProcessReply (Message msg, TimeSpan timeout); - - public override IAsyncResult BeginReply ( - Message msg, AsyncCallback callback, object state) - { - return BeginReply (msg, - channel.DefaultSendTimeout, - callback, state); - } - - Action<Message,TimeSpan> reply_delegate; - - public override IAsyncResult BeginReply ( - Message msg, TimeSpan timeout, - AsyncCallback callback, object state) - { - if (reply_delegate == null) - reply_delegate = new Action<Message,TimeSpan> (Reply); - return reply_delegate.BeginInvoke (msg, timeout, callback, state); - } - - public override void EndReply (IAsyncResult result) - { - if (result == null) - throw new ArgumentNullException ("result"); - if (reply_delegate == null) - throw new InvalidOperationException ("reply operation has not started"); - reply_delegate.EndInvoke (result); - } - - public override void Reply (Message msg) - { - Reply (msg, channel.DefaultSendTimeout); - } - - public override void Reply (Message msg, TimeSpan timeout) - { - ProcessReply (msg, timeout); - } - - public override void Close () - { - Close (Channel.DefaultSendTimeout); - } - } -} diff --git a/mcs/class/System.ServiceModel/old-code/SecurityHandler.cs b/mcs/class/System.ServiceModel/old-code/SecurityHandler.cs deleted file mode 100644 index 3b40d3b57ae..00000000000 --- a/mcs/class/System.ServiceModel/old-code/SecurityHandler.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ServiceModel.Channels; -using System.ServiceModel.Channels.Security; -using System.ServiceModel; -using System.ServiceModel.Security.Tokens; - -namespace System.ServiceModel.Dispatcher -{ - internal class SecurityHandler : BaseRequestProcessorHandler - { - protected override bool ProcessRequest (MessageProcessingContext mrc) - { - DispatchRuntime dispatch_runtime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime; - - // FIXME: I doubt this should be done at this "handler" - // layer, especially considering about non-ServiceHost - // use of SecurityBindingElement + listener. - // - // For example there is no way to handle it in duplex - // dispatch callbacks. - if (dispatch_runtime.ChannelDispatcher == null) - return false; - - Message negoResponce = null; - // process WS-Trust based negotiation - MessageSecurityBindingSupport support = - dispatch_runtime.ChannelDispatcher.Listener.GetProperty<MessageSecurityBindingSupport> (); - if (support != null && mrc.IncomingMessage.Headers.FindHeader ("Security", Constants.WssNamespace) < 0) { - CommunicationSecurityTokenAuthenticator nego = - support.TokenAuthenticator as CommunicationSecurityTokenAuthenticator; - if (nego != null) - negoResponce = nego.Communication.ProcessNegotiation (mrc.IncomingMessage); - } - - if (negoResponce == null) - return false; - - ReplyNegoResponse (mrc, negoResponce); - return true; - - } - - void ReplyNegoResponse (MessageProcessingContext mrc, Message negoResponse) - { - negoResponse.Headers.CopyHeadersFrom (mrc.OperationContext.OutgoingMessageHeaders); - negoResponse.Properties.CopyProperties (mrc.OperationContext.OutgoingMessageProperties); - mrc.RequestContext.Reply (negoResponse, mrc.Operation.Parent.ChannelDispatcher.timeouts.SendTimeout); - return; - } - } -} |