Decode() public method

If stream is null or not readable. If stream contents cannot be decoded properly.
public Decode ( string contentType, Stream stream, Encoding encoding ) : HttpForm
contentType string Should contain boundary and type, as in: multipart/form-data; boundary=---------------------------230051238959
stream Stream Stream containg form data.
encoding System.Text.Encoding Encoding used when decoding the stream
return HttpServer.HttpForm
Ejemplo n.º 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)
 {
     _form = providers.Decode(_headers["content-type"], _body, Encoding.UTF8);
 }
Ejemplo n.º 2
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 have not yet been completed.");

      _form = providers.Decode(_headers["content-type"], _body, Encoding.UTF8);
      if (_form != HttpInput.Empty)
        _param.SetForm(_form);
    }
Ejemplo n.º 3
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);
        }