/// <summary>
        /// Initializes a new instance of the <see cref="HttpRequestHeaderParser"/> class.
        /// </summary>
        /// <param name="httpRequest">The parsed HTTP request without any header sorting.</param>
        /// <param name="maxRequestLineSize">The max length of the HTTP request line.</param>
        /// <param name="maxHeaderSize">The max length of the HTTP header.</param>
        public HttpRequestHeaderParser(HttpUnsortedRequest httpRequest, int maxRequestLineSize, int maxHeaderSize)
        {
            if (httpRequest == null)
            {
                throw Error.ArgumentNull("httpRequest");
            }

            this._httpRequest = httpRequest;

            // Create request line parser
            this._requestLineParser = new HttpRequestLineParser(this._httpRequest, maxRequestLineSize);

            // Create header parser
            this._headerParser = new InternetMessageFormatHeaderParser(this._httpRequest.HttpHeaders, maxHeaderSize);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpResponseHeaderParser"/> class.
        /// </summary>
        /// <param name="httpResponse">The parsed HTTP response without any header sorting.</param>
        /// <param name="maxResponseLineSize">The max length of the HTTP status line.</param>
        /// <param name="maxHeaderSize">The max length of the HTTP header.</param>
        public HttpResponseHeaderParser(HttpUnsortedResponse httpResponse, int maxResponseLineSize, int maxHeaderSize)
        {
            if (httpResponse == null)
            {
                throw Error.ArgumentNull("httpResponse");
            }

            this._httpResponse = httpResponse;

            // Create status line parser
            this._statusLineParser = new HttpStatusLineParser(this._httpResponse, maxResponseLineSize);

            // Create header parser
            this._headerParser = new InternetMessageFormatHeaderParser(this._httpResponse.HttpHeaders, maxHeaderSize);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpResponseHeaderParser"/> class.
        /// </summary>
        /// <param name="httpResponse">The parsed HTTP response without any header sorting.</param>
        /// <param name="maxResponseLineSize">The max length of the HTTP status line.</param>
        /// <param name="maxHeaderSize">The max length of the HTTP header.</param>
        public HttpResponseHeaderParser(HttpUnsortedResponse httpResponse, int maxResponseLineSize, int maxHeaderSize)
        {
            if (httpResponse == null)
            {
                throw Error.ArgumentNull("httpResponse");
            }

            this._httpResponse = httpResponse;

            // Create status line parser
            this._statusLineParser = new HttpStatusLineParser(this._httpResponse, maxResponseLineSize);

            // Create header parser
            this._headerParser = new InternetMessageFormatHeaderParser(this._httpResponse.HttpHeaders, maxHeaderSize);
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpRequestHeaderParser"/> class.
        /// </summary>
        /// <param name="httpRequest">The parsed HTTP request without any header sorting.</param>
        /// <param name="maxRequestLineSize">The max length of the HTTP request line.</param>
        /// <param name="maxHeaderSize">The max length of the HTTP header.</param>
        public HttpRequestHeaderParser(HttpUnsortedRequest httpRequest, int maxRequestLineSize, int maxHeaderSize)
        {
            if (httpRequest == null)
            {
                throw Error.ArgumentNull("httpRequest");
            }

            this._httpRequest = httpRequest;

            // Create request line parser
            this._requestLineParser = new HttpRequestLineParser(this._httpRequest, maxRequestLineSize);

            // Create header parser
            this._headerParser = new InternetMessageFormatHeaderParser(this._httpRequest.HttpHeaders, maxHeaderSize);
        }
        public ParserState ParseBuffer(
            byte[] buffer,
            int bytesReady,
            ref int bytesConsumed)
        {
            if (buffer == null)
            {
                throw Error.ArgumentNull("buffer");
            }

            ParserState parseStatus = ParserState.NeedMoreData;

            if (bytesConsumed >= bytesReady)
            {
                // We already can tell we need more data
                return(parseStatus);
            }

            try
            {
                parseStatus = InternetMessageFormatHeaderParser.ParseHeaderFields(
                    buffer,
                    bytesReady,
                    ref bytesConsumed,
                    ref this._headerState,
                    this._maxHeaderSize,
                    ref this._totalBytesConsumed,
                    this._currentHeader,
                    this._headers);
            }
            catch (Exception)
            {
                parseStatus = ParserState.Invalid;
            }

            return(parseStatus);
        }