Change HttpResponseStreamWriter.DefaultBufferSize to 16K and remove it from public API surface
This commit is contained in:
parent
62fdf64cf6
commit
64c6e11ce4
|
|
@ -16,11 +16,7 @@ namespace Microsoft.AspNetCore.WebUtilities
|
||||||
public class HttpResponseStreamWriter : TextWriter
|
public class HttpResponseStreamWriter : TextWriter
|
||||||
{
|
{
|
||||||
private const int MinBufferSize = 128;
|
private const int MinBufferSize = 128;
|
||||||
|
internal const int DefaultBufferSize = 16 * 1024;
|
||||||
/// <summary>
|
|
||||||
/// Default buffer size.
|
|
||||||
/// </summary>
|
|
||||||
public const int DefaultBufferSize = 1024;
|
|
||||||
|
|
||||||
private Stream _stream;
|
private Stream _stream;
|
||||||
private readonly Encoder _encoder;
|
private readonly Encoder _encoder;
|
||||||
|
|
@ -50,39 +46,19 @@ namespace Microsoft.AspNetCore.WebUtilities
|
||||||
ArrayPool<byte> bytePool,
|
ArrayPool<byte> bytePool,
|
||||||
ArrayPool<char> charPool)
|
ArrayPool<char> charPool)
|
||||||
{
|
{
|
||||||
if (stream == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(stream));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stream.CanWrite)
|
if (!stream.CanWrite)
|
||||||
{
|
{
|
||||||
throw new ArgumentException(Resources.HttpResponseStreamWriter_StreamNotWritable, nameof(stream));
|
throw new ArgumentException(Resources.HttpResponseStreamWriter_StreamNotWritable, nameof(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoding == null)
|
Encoding = encoding ?? throw new ArgumentNullException(nameof(encoding));
|
||||||
{
|
_bytePool = bytePool ?? throw new ArgumentNullException(nameof(bytePool));
|
||||||
throw new ArgumentNullException(nameof(encoding));
|
_charPool = charPool ?? throw new ArgumentNullException(nameof(charPool));
|
||||||
}
|
_stream = stream ?? throw new ArgumentNullException(nameof(stream));
|
||||||
|
|
||||||
if (bytePool == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(bytePool));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (charPool == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(charPool));
|
|
||||||
}
|
|
||||||
|
|
||||||
_stream = stream;
|
|
||||||
Encoding = encoding;
|
|
||||||
_charBufferSize = bufferSize;
|
_charBufferSize = bufferSize;
|
||||||
|
|
||||||
_encoder = encoding.GetEncoder();
|
_encoder = encoding.GetEncoder();
|
||||||
_bytePool = bytePool;
|
|
||||||
_charPool = charPool;
|
|
||||||
|
|
||||||
_charBuffer = charPool.Rent(bufferSize);
|
_charBuffer = charPool.Rent(bufferSize);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"TypeId": "public class Microsoft.AspNetCore.WebUtilities.HttpResponseStreamWriter : System.IO.TextWriter",
|
||||||
|
"MemberId": "public const System.Int32 DefaultBufferSize = 1024",
|
||||||
|
"Kind": "Removal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -161,10 +161,10 @@ namespace Microsoft.AspNetCore.WebUtilities.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(1023)]
|
[InlineData(HttpResponseStreamWriter.DefaultBufferSize - 1)]
|
||||||
[InlineData(1024)]
|
[InlineData(HttpResponseStreamWriter.DefaultBufferSize)]
|
||||||
[InlineData(1050)]
|
[InlineData(HttpResponseStreamWriter.DefaultBufferSize + 1)]
|
||||||
[InlineData(2048)]
|
[InlineData(HttpResponseStreamWriter.DefaultBufferSize * 2)]
|
||||||
public async Task FlushesBuffer_ButNotStream_OnFlushAsync(int byteLength)
|
public async Task FlushesBuffer_ButNotStream_OnFlushAsync(int byteLength)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue