Exemple #1
0
        /// <summary>
        /// Creates a new instance with the specified parameters.
        /// </summary>
        /// <param name="maxInitialLineLength"></param>
        /// <param name="maxHeaderSize"></param>
        /// <param name="maxChunkSize"></param>
        /// <param name="chunkedSupported"></param>
        /// <param name="validateHeaders"></param>
        /// <param name="initialBufferSize"></param>
        protected HttpObjectDecoder(
            int maxInitialLineLength, int maxHeaderSize, int maxChunkSize,
            bool chunkedSupported, bool validateHeaders, int initialBufferSize)
        {
            if ((uint)(maxInitialLineLength - 1) > SharedConstants.TooBigOrNegative)
            {
                ThrowHelper.ThrowArgumentException_Positive(maxInitialLineLength, ExceptionArgument.maxInitialLineLength);
            }
            if ((uint)(maxHeaderSize - 1) > SharedConstants.TooBigOrNegative)
            {
                ThrowHelper.ThrowArgumentException_Positive(maxHeaderSize, ExceptionArgument.maxHeaderSize);
            }
            if ((uint)(maxChunkSize - 1) > SharedConstants.TooBigOrNegative)
            {
                ThrowHelper.ThrowArgumentException_Positive(maxChunkSize, ExceptionArgument.maxChunkSize);
            }

            var seq = new AppendableCharSequence(initialBufferSize);

            _lineParser       = new LineParser(this, seq, maxInitialLineLength);
            _headerParser     = new HeaderParser(seq, maxHeaderSize);
            _maxChunkSize     = maxChunkSize;
            _chunkedSupported = chunkedSupported;
            ValidateHeaders   = validateHeaders;
        }
Exemple #2
0
        public QueryStringDecoder(string uri, Encoding charset, bool hasPath, int maxParams, bool semicolonIsNormalChar)
        {
            if (uri is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.uri);
            }
            if (charset is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.charset);
            }
            if ((uint)(maxParams - 1) > SharedConstants.TooBigOrNegative)
            {
                ThrowHelper.ThrowArgumentException_Positive(maxParams, ExceptionArgument.maxParams);
            }

            _uri                   = uri;
            _charset               = charset;
            _maxParams             = maxParams;
            _semicolonIsNormalChar = semicolonIsNormalChar;

            // -1 means that path end index will be initialized lazily
            _pathEndIdx = hasPath ? -1 : 0;
        }
Exemple #3
0
        public QueryStringDecoder(Uri uri, Encoding charset, int maxParams, bool semicolonIsNormalChar)
        {
            if (uri is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.uri);
            }
            if (charset is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.charset);
            }
            if ((uint)(maxParams - 1) > SharedConstants.TooBigOrNegative)
            {
                ThrowHelper.ThrowArgumentException_Positive(maxParams, ExceptionArgument.maxParams);
            }

            string rawPath = uri.AbsolutePath;

            // Also take care of cut of things like "http://localhost"
            _uri                   = uri.PathAndQuery;
            _charset               = charset;
            _maxParams             = maxParams;
            _semicolonIsNormalChar = semicolonIsNormalChar;
            _pathEndIdx            = rawPath.Length;
        }