public Task Invoke(IDictionary <string, object> arg) { var env = new OwinEnvironment(arg); if (env.TryGetValue(OwinEnvironment.PeerCastStation.AccessControlInfo, out AccessControlInfo acinfo) && (acinfo.Accepts & acceptType) != 0) { if (acinfo.AuthorizationRequired) { if (CheckAuthorization(GetAuthorizationToken(env), acinfo)) { return(nextApp.Invoke(arg)); } else { env.Environment[OwinEnvironment.Owin.ResponseStatusCode] = 401; env.SetResponseHeader("WWW-Authenticate", "Basic realm=\"PeerCastStation\""); return(Task.Delay(0)); } } else { return(nextApp.Invoke(arg)); } } else { env.Environment[OwinEnvironment.Owin.ResponseStatusCode] = 403; return(Task.Delay(0)); } }
public Task Invoke(IDictionary <string, object> arg) { var env = new OwinEnvironment(arg); var pathMatch = pathPattern.Match(env.Request.Path); if (pathMatch.Success) { if (env.TryGetValue(OwinEnvironment.Owin.RequestMethod, out string method) && methods.Contains(method)) { env.Response.StatusCode = System.Net.HttpStatusCode.OK; env.Environment[OwinEnvironment.Owin.RequestPathMatch] = pathMatch; var pathBase = env.Get(OwinEnvironment.Owin.RequestPathBase, ""); env.Environment[OwinEnvironment.Owin.RequestPathBase] = pathBase + pathMatch.Value; env.Environment[OwinEnvironment.Owin.RequestPath] = env.Request.Path.Substring(pathMatch.Length); env.RemoveResponseHeader("Allow"); return(branch.Invoke(arg)); } else { env.Response.StatusCode = System.Net.HttpStatusCode.MethodNotAllowed; var allow = env.GetResponseHeader("Allow", (string)null); if (allow == null) { allow = String.Join(", ", methods); } else { allow = String.Join(", ", Enumerable.Repeat(allow, 1).Concat(methods)); } env.SetResponseHeader("Allow", allow); } } return(nextApp.Invoke(arg)); }
public Task Invoke(IDictionary <string, object> arg) { var env = new OwinEnvironment(arg); if (env.TryGetValue(OwinEnvironment.Owin.RequestMethod, out string method) && methods.Contains(method)) { return(branch.Invoke(arg)); } else { return(nextApp.Invoke(arg)); } }
public Task Invoke(IDictionary <string, object> arg) { var env = new OwinEnvironment(arg); if (env.TryGetValue(OwinEnvironment.Owin.RequestMethod, out string method) && methods.Contains(method)) { return(nextApp.Invoke(arg)); } else { env.Environment[OwinEnvironment.Owin.ResponseStatusCode] = (int)HttpStatusCode.MethodNotAllowed; env.SetResponseHeader("Allow", String.Join(",", methods)); return(Task.Delay(0)); } }