Ejemplo n.º 1
0
        /// <summary>
        /// We've parsed a new header.
        /// </summary>
        /// <param name="name">Name in lower case</param>
        /// <param name="value">Value, unmodified.</param>
        /// <exception cref="BadRequestException">If content length cannot be parsed.</exception>
        protected void OnHeader(string name, string value)
        {
            m_headerArgs.Name  = name;
            m_headerArgs.Value = value;
            if (string.Compare(name, "content-length", true) == 0)
            {
                if (!int.TryParse(value, out m_bodyBytesLeft))
                {
                    throw new BadRequestException("Content length is not a number.");
                }
            }

            HeaderReceived?.Invoke(this, m_headerArgs);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// We've parsed a new header.
        /// </summary>
        /// <param name="name">Name in lower case</param>
        /// <param name="value">Value, unmodified.</param>
        /// <exception cref="BadRequestException">If content length cannot be parsed.</exception>
        protected void OnHeader()
        {
            if (string.Compare(m_curHeaderName, "content-length", true) == 0)
            {
                if (!int.TryParse(m_curHeaderValue, out m_bodyBytesLeft))
                {
                    throw new BadRequestException("Content length is not a number.");
                }
            }

            if (HeaderReceived != null)
            {
                m_headerArgs.Name  = m_curHeaderName;
                m_headerArgs.Value = m_curHeaderValue;
                HeaderReceived?.Invoke(this, m_headerArgs);
            }

            m_curHeaderName  = string.Empty;
            m_curHeaderValue = string.Empty;
        }