src/packages/EmbedIO/HttpContextExtensions-ResponseStream.cs
/// <summary>
/// <para>Wraps the response output stream and returns a <see cref="TextWriter" /> that can be used directly.</para>
/// <para>Optional buffering is applied, so that the response may be sent as one (thereby properly setting the
/// <c>Content-Length</c> header) instead of using chunked transfer.</para>
/// <para>Proactive negotiation is performed to select the best compression method supported by the client.</para>
/// </summary>
/// <param name="this">The <see cref="IHttpContext" /> on which this method is called.</param>
/// <param name="encoding">The <see cref="Encoding"/> to use to convert text to data bytes.
/// By default, <see cref="Encoding.UTF8">UTF-8</see> is used.</param>
/// <param name="buffered">If set to <see langword="true" />, sent data is collected
/// in a <see cref="MemoryStream" /> and sent all at once when the returned <see cref="Stream" />
/// is disposed; if set to <see langword="false" /> (the default), chunked transfer will be used.</param>
/// <param name="preferCompression"><see langword="true"/> if sending compressed data is preferred over
/// sending non-compressed data; otherwise, <see langword="false"/>.</param>
/// <returns>
/// <para>A <see cref="TextWriter" /> that can be used to write response data.</para>
/// <para>This writer MUST be disposed when finished writing.</para>
/// </returns>
/// <seealso cref="OpenResponseStream"/>
Wraps the response output stream and returns a  that can be used directly.Optional buffering is applied, so that the response may be sent as one (thereby properly setting the
Content-LengthProactive negotiation is performed to select the best compression method supported by the client.
Wraps the response output stream and returns a that can be used directly . Optional buffering is applied so that the response may be sent as one ( thereby properly setting the Content - LengthProactive negotiation is performed to select the best compression method supported by the client .
public static TextWriter OpenResponseText(this IHttpContext @this, [DisallowNull] Encoding? encoding = null, bool buffered = false, bool preferCompression = true)
        {
            encoding ??= Encoding.UTF8;
            @this.Response.ContentEncoding = encoding;
            return new StreamWriter(OpenResponseStream(@this, buffered, preferCompression), encoding);
        }
public static TextWriter OpenResponseText ( this IHttpContext @this , [ DisallowNull ] Encoding ? encoding = null , bool buffered = false , bool preferCompression = true ) { encoding ??= Encoding . UTF8 ; @this . Response . ContentEncoding = encoding ; return new StreamWriter ( OpenResponseStream ( @this , buffered , preferCompression ) , encoding ) ; }
Wraps the response output stream and returns a  that can be used directly.Optional buffering is applied, so that the response may be sent as one (thereby properly setting the
Content-LengthProactive negotiation is performed to select the best compression method supported by the client.
Wraps the response output stream and returns a that can be used directly . Optional buffering is applied so that the response may be sent as one ( thereby properly setting the Content - LengthProactive negotiation is performed to select the best compression method supported by the client .
A  that can be used to write response data.This writer MUST be disposed when finished writing.
A that can be used to write response data . This writer MUST be disposed when finished writing .
IHttpContext
this
Encoding?
[DisallowNull]
buffered
bool
If set to , sent data is collected
in a  and sent all at once when the returned
is disposed; if set to  (the default), chunked transfer will be used.
If set to sent data is collected in a and sent all at once when the returned is disposed ; if set to ( the default ) chunked transfer will be used .
preferCompression
bool
if sending compressed data is preferred over
sending non-compressed data; otherwise, .
if sending compressed data is preferred over sending non - compressed data ; otherwise .
this
The  on which this method is called.
The on which this method is called .
encoding
None
seealso
None