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) waiting.Add (sctx.Source); SignalAsyncWait (); }
internal bool FilterHttpContext (HttpContextInfo ctx) { if (ctx.HttpMethod.ToUpper () != "GET") return mex_info == null; if (wsdl_instance == null) return true; if (channel_listener.State != CommunicationState.Opened) return true; if (wsdl_instance.WsdlUrl != null && Uri.Compare (ctx.RequestUrl, wsdl_instance.WsdlUrl, cmpflag, fmtflag, StringComparison.Ordinal) == 0) { if (mex_info == null) return false; // Do not handle this at normal dispatcher. if (ctx.QueryString [null] == "wsdl") return mex_info.SupportsMex; // wsdl dispatcher should handle this. if (!wsdl_instance.HelpUrl.Equals (wsdl_instance.WsdlUrl)) return true; // in case help URL is not equivalent to WSDL URL, it anyways returns WSDL regardless of ?wsdl existence. } if (wsdl_instance.HelpUrl != null && Uri.Compare (ctx.RequestUrl, wsdl_instance.HelpUrl, cmpflag, fmtflag, StringComparison.Ordinal) == 0) { // Do not handle this at normal dispatcher. // Do return true otherwise, even if it is with "?wsdl". // (It must be handled above if applicable.) return mex_info != null; } return mex_info == 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 (); }
static void AddListenerContext (HttpListenerManager lm, HttpContextInfo ctx) { lock (registered_channels) { lm.pending.Add (ctx); // FIXME: this should not be required, but it somehow saves some failures wrt concurrent calls. Thread.Sleep (100); lm.wait_http_ctx.Set (); } }
void DispatchHttpListenerContext (HttpContextInfo ctx) { if (wsdl_instance == null) { AddListenerContext (this, ctx); return; } foreach (var l in registered_channels [channel_listener.Uri]) { var lm = l.GetProperty<HttpListenerManager> (); if (lm.FilterHttpContext (ctx)) { AddListenerContext (lm, ctx); return; } } AddListenerContext (this, ctx); }
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); }
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 (); } }
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); }