public Decode ( string contentType, Stream stream, |
||
contentType | string | Should contain boundary and type, as in: multipart/form-data; boundary=---------------------------230051238959 |
stream | Stream | Stream containg form data. |
encoding | Encoding used when decoding the stream | |
Результат |
/// <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); }
/// <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); }
/// <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); }