private void GenerateResponse(FastCGIRequestAsync request,FastCGIResponseAsync response)
        {
            var handler = handlers[request.Params["SCRIPT_FILENAME"]];

            FastCGIRequest requestArg = new FastCGIRequest(request);

            var responseResult = handler(requestArg);

            response.StdOutWriter.WriteLine("Hi!");
        }
        internal void WriteToResponse(FastCGIResponseAsync asyncResponse)
        {
            asyncResponse.Headers.Add("Status", ((int)StatusCode).ToString());

            foreach (var header in Headers.AllKeys)
            {
                asyncResponse.Headers.Add(header, Headers.Get(header));
            }

            OutputStream.CopyTo(asyncResponse.StdOutStream);
        }
 private void HandleRequest(FastCGIRequestAsync request, FastCGIResponseAsync response)
 {
     if (!handlers.ContainsKey(request.Params["SCRIPT_FILENAME"]))
     {
         GenerateNotFoundResponse(response);
     }
     else
     {
         GenerateResponse(request, response);
     }
 }
        public FastCGIServerClientRequestHandlerAsync(FastCGIServerClientHandlerAsync FastcgiServerClientHandlerAsync, Stream ClientStream, ushort RequestId)
        {
            this.FastcgiServerClientHandlerAsync = FastcgiServerClientHandlerAsync;
            this.ClientStream        = ClientStream;
            this.RequestId           = RequestId;
            this.FastcgiRequestAsync = new FastCGIRequestAsync()
            {
                StdInStream = new FastCGIInputStream(),
            };
            this.FastcgiResponseAsync = new FastCGIResponseAsync()
            {
                StdOutStream = new FastCGIOutputStream(),
                StdErrStream = new FastCGIOutputStream(),
                Headers      = new FastCGIHeaders(),
            };

            this.FastcgiResponseAsync.StdOutWriter           = new StreamWriter(this.FastcgiResponseAsync.StdOutStream);
            this.FastcgiResponseAsync.StdOutWriter.AutoFlush = true;

            this.FastcgiResponseAsync.StdErrWriter           = new StreamWriter(this.FastcgiResponseAsync.StdErrStream);
            this.FastcgiResponseAsync.StdErrWriter.AutoFlush = true;
        }
        public FastCGIServerClientRequestHandlerAsync(FastCGIServerClientHandlerAsync FastcgiServerClientHandlerAsync, Stream ClientStream, ushort RequestId)
		{
			this.FastcgiServerClientHandlerAsync = FastcgiServerClientHandlerAsync;
			this.ClientStream = ClientStream;
			this.RequestId = RequestId;
			this.FastcgiRequestAsync = new FastCGIRequestAsync()
			{
				StdInStream = new FastCGIInputStream(),
			};
			this.FastcgiResponseAsync = new FastCGIResponseAsync()
			{
				StdOutStream = new FastCGIOutputStream(),
                StdErrStream = new FastCGIOutputStream(),
				Headers = new FastCGIHeaders(),
			};

			this.FastcgiResponseAsync.StdOutWriter = new StreamWriter(this.FastcgiResponseAsync.StdOutStream);
			this.FastcgiResponseAsync.StdOutWriter.AutoFlush = true;

			this.FastcgiResponseAsync.StdErrWriter = new StreamWriter(this.FastcgiResponseAsync.StdErrStream);
			this.FastcgiResponseAsync.StdErrWriter.AutoFlush = true;
		}
 private void GenerateNotFoundResponse(FastCGIResponseAsync response)
 {
     response.Headers.Add("Status", "404 Not Found");
 }
        public override Task HandleRequestAsync(FastCGIRequestAsync request, FastCGIResponseAsync response)
        {
            Action<FastCGIRequestAsync,FastCGIResponseAsync> action = this.HandleRequest;

            return Task.Factory.FromAsync(action.BeginInvoke, action.EndInvoke, request, response, null);
        }
예제 #8
0
 public abstract Task HandleRequestAsync(FastCGIRequestAsync Request, FastCGIResponseAsync Response);