/// <summary>
            /// Initializes a new instance of the <see cref="RequestHandler" /> class.
            /// </summary>
            /// <param name="handler">The underlying client connection handler.</param>
            /// <param name="record">The value for the <see cref="RequestHandler.BaseRecord" /> property.</param>
            /// <param name="level">The value for the <see cref="RequestHandler.Level" /> property.</param>
            /// <exception cref="ArgumentNullException">
            /// At least one parameter is <see langword="null" />.
            /// </exception>
            public RequestHandler(TcpClientConnectionHandler handler, BeginRequestRecord record, int level)
            {
                if (handler == null)
                {
                    throw new ArgumentNullException("handler");
                }

                if (record == null)
                {
                    throw new ArgumentNullException("record");
                }

                this.BaseRecord = record;
                this.Level = level;
                this.Handler = handler;

                this._CONTEXT = new RequestContext(this);
                this._CONTEXT.Address = this.Server._SETTINGS.LocalAddress ?? IPAddress.Loopback;
                this._CONTEXT.Port = this.Server._SETTINGS.Port;

                int? readBufferSize = null;
                int? writeBufferSize = null;
                this._CONTEXT.BodyStream = this._CONTEXT.CreateInputStream(ref readBufferSize, ref writeBufferSize);

                this._CONTEXT.ReadBufferSize = readBufferSize;
                if (this._CONTEXT.ReadBufferSize < 1)
                {
                    this._CONTEXT.ReadBufferSize = 10240;
                }

                this._CONTEXT.WriteBufferSize = writeBufferSize;
                if (this._CONTEXT.WriteBufferSize < 1)
                {
                    this._CONTEXT.WriteBufferSize = 10240;
                }

                this._CONTEXT.Ended += this._CONTEXT_Ended;
            }
            /// <summary>
            /// Begins a request.
            /// </summary>
            /// <param name="record">The record.</param>
            /// <param name="level">The level.</param>
            public void BeginRequest(BeginRequestRecord record, int level = 0)
            {
                this.CloseConnection = record.CloseConnection ?? true;

                var handler = new RequestHandler(this, record, level);
                handler.HandleNext();
            }