Пример #1
0
        /// <summary>
        /// Decode body into a form.
        /// </summary>
        /// <param name="providers">A list with form decoders.</param>
        /// <exception cref="InvalidDataException">If body contents is not valid for the chosen decoder.</exception>
        /// <exception cref="InvalidOperationException">If body is still being transferred.</exception>
        public void DecodeBody(FormDecoderProvider providers)
        {
            if (_bodyBytesLeft > 0)
            {
                throw new InvalidOperationException("Body transfer has not yet been completed.");
            }

            Encoding encoding    = null;
            string   encodingStr = this.Headers["content-encoding"];

            if (!String.IsNullOrEmpty(encodingStr))
            {
                try { encoding = Encoding.GetEncoding(encodingStr); }
                catch { }
            }
            if (encoding == null)
            {
                encoding = Encoding.UTF8;
            }

            _form = providers.Decode(_headers["content-type"], _body, encoding);
            if (_form != HttpInput.Empty)
            {
                _param.SetForm(_form);
            }
        }
Пример #2
0
 /// <summary>
 /// Assign a form.
 /// </summary>
 /// <param name="form"></param>
 internal void AssignForm(HttpForm form)
 {
     _form = form;
 }