internal HttpResponse(StateObject state, Request req) : base(state, req) { this.Headers = new NameValueCollection(); this.Headers.Add("Server", "Fusion"); this.Headers.Add("Date", DateTime.Now.ToUniversalTime().ToString()); this.Status = "200 OK"; }
public static MiddlewareState DebugInbound(Request req, Response res) { if (req is Http.HttpRequest) { Http.HttpRequest hreq = (Http.HttpRequest)req; Console.WriteLine(" ** Request: " + hreq.Verb + " " + hreq.Path); } else Console.WriteLine(" ** Inbound: " + req.Body + "<END>"); return new MiddlewareState(req, res); }
internal void OnRequestHandler(Request req, Response res) { MiddlewareState state = new MiddlewareState(req, res); if (this.RequestModules != null) { // Invoke each request middleware foreach (RequestMiddleware rm in this.RequestModules) state = rm(state.Request, state.Response); } // Call the original handler with the modified state this.Handler(state.Request, state.Response); }
public MiddlewareState(Request req, Response res) { this.Request = req; this.Response = res; }
internal Response(StateObject state, Request req) { this.Buffer = new byte[0]; this.NetState = state; this.Request = req; }