示例#1
0
        /// <summary>
        /// Used internally. Feeds a <see cref="Record">Record</see> to this request for processing.
        /// </summary>
        /// <param name="record">The record to feed.</param>
        /// <returns>Returns true iff the request is completely received.</returns>
        internal bool HandleRecord(Record record)
        {
            switch (record.Type)
            {
            case Record.RecordType.Params:

                if (record.ContentLength == 0)
                {
                    ParamStream.Seek(0, SeekOrigin.Begin);
                    Parameters = Record.ReadNameValuePairs(ParamStream);
                }
                else
                {
                    // If the params are not yet finished, write the contents to the ParamStream.
                    ParamStream.Write(record.ContentData, 0, record.ContentLength);
                }
                break;

            case Record.RecordType.Stdin:
                string data = Encoding.ASCII.GetString(record.ContentData);
                Body += data;

                // Finished requests are indicated by an empty stdin record
                if (record.ContentLength == 0)
                {
                    return(true);
                }

                break;
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Used internally. Feeds a <see cref="Record">Record</see> to this request for processing.
        /// </summary>
        /// <param name="record">The record to feed.</param>
        /// <returns>Returns true iff the request is completely received.</returns>
        internal bool HandleRecord(Record record)
        {
            switch (record.Type)
            {
            case Record.RecordType.Params:
                // An empty parameter record specifies that all parameters have been transmitted
                if (record.ContentLength == 0)
                {
                    ParamStream.Seek(0, SeekOrigin.Begin);
                    Parameters         = Record.ReadNameValuePairs(ParamStream);
                    FinishedParameters = true;
                }
                else
                {
                    // If the params are not yet finished, write the contents to the ParamStream.
                    ParamStream.Write(record.ContentData, 0, record.ContentLength);
                }
                break;

            case Record.RecordType.Stdin:
                var oldPos = RequestBodyStream.Position;
                RequestBodyStream.Seek(0, SeekOrigin.End);
                RequestBodyStream.Write(record.ContentData, 0, record.ContentLength);
                RequestBodyStream.Position = oldPos;

                // Finished requests are indicated by an empty stdin record
                if (record.ContentLength == 0)
                {
                    FinishedRequestBody = true;
                    return(true);
                }

                break;
            }
            return(false);
        }