protected virtual void DecodeBody(IRequest request)
{
Encoding encoding = null;
if (request.ContentType != null)
{
string encodingStr = request.ContentType.Parameters["Encoding"];
if (!string.IsNullOrEmpty(encodingStr))
encoding = Encoding.GetEncoding(encodingStr);
}
if (encoding == null)
encoding = Encoding.UTF8;
// process body.
DecodedData data = _bodyDecoders.Decode(request.Body, request.ContentType, encoding);
if (data == null)
return;
if (!(request is Request))
throw new InternalServerException("Request object has to derive from Request (sorry for breaking LSP).");
var r = (Request) request;
r.Files = data.Files;
r.Form = data.Parameters;
}