src/packages/EmbedIO/HttpContextExtensions-RequestStream.cs
/// <summary>
/// <para>Wraps the request input stream and returns a <see cref="Stream"/> that can be used directly.</para>
/// <para>Decompression of compressed request bodies is implemented if specified in the web server's options.</para>
/// </summary>
/// <param name="this">The <see cref="IHttpContext"/> on which this method is called.</param>
/// <returns>
/// <para>A <see cref="Stream"/> that can be used to write response data.</para>
/// <para>This stream MUST be disposed when finished writing.</para>
/// </returns>
/// <seealso cref="OpenRequestText"/>
/// <seealso cref="WebServerOptionsBase.SupportCompressedRequests"/>
Wraps the request input stream and returns a  that can be used directly.Decompression of compressed request bodies is implemented if specified in the web server's options.
Wraps the request input stream and returns a that can be used directly . Decompression of compressed request bodies is implemented if specified in the web server ' s options .
public static Stream OpenRequestStream(this IHttpContext @this)
        {
            var stream = @this.Request.InputStream;
            var encoding = @this.Request.Headers[HttpHeaderNames.ContentEncoding]?.Trim();
            switch (encoding)
            {
                case CompressionMethodNames.Gzip:
                    if (@this.SupportCompressedRequests)
                        return new GZipStream(stream, CompressionMode.Decompress);
                    break;
                case CompressionMethodNames.Deflate:
                    if (@this.SupportCompressedRequests)
                        return new DeflateStream(stream, CompressionMode.Decompress);
                    break;
                case CompressionMethodNames.None:
                case null:
                    return stream;
            }
            $"[{@this.Id}] Unsupported request content encoding \"{encoding}\", sending 400 Bad Request..."
                .Warn(nameof(OpenRequestStream));
            throw HttpException.BadRequest($"Unsupported content encoding \"{encoding}\"");
        }
public static Stream OpenRequestStream ( this IHttpContext @this ) { var stream = @this . Request . InputStream ; var encoding = @this . Request . Headers [ HttpHeaderNames . ContentEncoding ] ? . Trim ( ) ; switch ( encoding ) { case CompressionMethodNames . Gzip : if ( @this . SupportCompressedRequests ) return new GZipStream ( stream , CompressionMode . Decompress ) ; break ; case CompressionMethodNames . Deflate : if ( @this . SupportCompressedRequests ) return new DeflateStream ( stream , CompressionMode . Decompress ) ; break ; case CompressionMethodNames . None : case null : return stream ; } $" [ { @this . Id } ] Unsupported request content encoding  \" { encoding } \" , sending 400 Bad Request... " . Warn ( nameof ( OpenRequestStream ) ) ; throw HttpException . BadRequest ( $" Unsupported content encoding  \" { encoding } \" " ) ; }
Wraps the request input stream and returns a  that can be used directly.Decompression of compressed request bodies is implemented if specified in the web server's options.
Wraps the request input stream and returns a that can be used directly . Decompression of compressed request bodies is implemented if specified in the web server ' s options .
A  that can be used to write response data.This stream MUST be disposed when finished writing.
A that can be used to write response data . This stream MUST be disposed when finished writing .
IHttpContext
this
this
The  on which this method is called.
The on which this method is called .
seealso
None
seealso
None