Exemple #1
0
        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";
        }
Exemple #2
0
 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);
 }
Exemple #3
0
        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);
        }
Exemple #4
0
 public MiddlewareState(Request req, Response res)
 {
     this.Request = req;
     this.Response = res;
 }
Exemple #5
0
 internal Response(StateObject state, Request req)
 {
     this.Buffer = new byte[0];
     this.NetState = state;
     this.Request = req;
 }