コード例 #1
0
        private async Task DecompressRequest(IOwinContext context, IList<string> tmpContentEncoding, CancellationToken cancellationToken)
        {
            var tmpCompressor = GetCompressor(tmpContentEncoding);
            if (tmpCompressor == null)
            {
                throw new Exception(string.Format("Unable to decompress request, no valid compressor found for '{0}'",
                    tmpContentEncoding.ToStringExt()));
            }

            var tmpDestination = new MemoryStream();
            using (var tmpRequestBody = context.Request.Body)
            {
                await tmpCompressor.Decompress(tmpRequestBody, tmpDestination, cancellationToken);
            }
            //Rewind Stream, so Next() can read it
            tmpDestination.Position = 0;
            context.Request.Body = tmpDestination;
        }