Beispiel #1
0
        /// <summary>
        /// Creates and initalize a <typeparamref name="Request"/> 
        /// </summary>
        /// <param name="message">BeginRequest message</param>
        protected virtual void BeginRequest(Message message)
        {
            if (message.Header.RecordType != RecordType.Application)
                return;

            if (message.Body.Count < Consts.ChunkSize)
                return;

            Request request = this.CreateRequest(message.Header.RequestId, new BeginRequestMessageBody(message.Body));
            request.Ended += new EventHandler(OnRequestEnded);
            request.OutputFlushing += new EventHandler<FlushEventArgs>(OnRequestOutputFlushing);
            request.ErrorFlushing += new EventHandler<FlushEventArgs>(OnRequestErrorFlushing);

            this.AddRequest(request);
        }
Beispiel #2
0
        /// <summary>
        /// Process a received FastCGI message
        /// </summary>
        /// <param name="message"></param>
        protected virtual void ReceiveMessage(Message message)
        {
            ushort requestId = message.Header.RequestId;

            switch (message.Header.MessageType)
            {
                case MessageType.BeginRequest:
                    this.BeginRequest(message);
                    break;

                case MessageType.AbortRequest:
                    this.GetRequest(requestId).Abort();
                    break;

                case MessageType.Params:
                    this.GetRequest(requestId).ParametersStream.Append(message.Body);
                    break;

                case MessageType.StandardInput:
                    if (message.Header.ContentLength > 0)
                        this.GetRequest(requestId).InputStream.Append(message.Body);
                    else
                        this.GetRequest(requestId).Execute();
                    break;

                case MessageType.Data:
                    this.GetRequest(requestId).DataStream.Append(message.Body);
                    break;

                case MessageType.GetValues:
                    this.SendGetValuesResult(message.Body);
                    break;

                default:
                    break;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Sends a message to the FastCGI client
        /// </summary>
        /// <param name="message"><typeparamref name="Message"/> to send</param>
        public virtual void SendMessage(Message message)
        {
            var array = message.ToByteArray();
            Debug.WriteLine(array);

            this.LowerLayer.Send(array);
        }