aboutsummaryrefslogtreecommitdiff
path: root/SocketHttpListener.Portable/Net/ResponseStream.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-05-22 00:54:02 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-05-22 00:54:02 -0400
commit54cf0da75826d641b28a34afece7a4cb0eaaaec2 (patch)
tree8d6f313fe9d71a5ecaf7a235eff4c5db6e68990b /SocketHttpListener.Portable/Net/ResponseStream.cs
parent41ea0d99f4ee953d6e955c355cef0e5088f9b9fd (diff)
update query fields
Diffstat (limited to 'SocketHttpListener.Portable/Net/ResponseStream.cs')
-rw-r--r--SocketHttpListener.Portable/Net/ResponseStream.cs19
1 files changed, 5 insertions, 14 deletions
diff --git a/SocketHttpListener.Portable/Net/ResponseStream.cs b/SocketHttpListener.Portable/Net/ResponseStream.cs
index 149b24028..b2d0d4e9c 100644
--- a/SocketHttpListener.Portable/Net/ResponseStream.cs
+++ b/SocketHttpListener.Portable/Net/ResponseStream.cs
@@ -148,6 +148,7 @@ namespace SocketHttpListener.Net
}
const int MsCopyBufferSize = 81920;
+ const int StreamCopyToBufferSize = 81920;
public override void Write(byte[] buffer, int offset, int count)
{
if (disposed)
@@ -340,11 +341,11 @@ namespace SocketHttpListener.Net
{
if (allowAsync)
{
- await fs.CopyToAsync(targetStream, 81920, cancellationToken).ConfigureAwait(false);
+ await fs.CopyToAsync(targetStream, StreamCopyToBufferSize, cancellationToken).ConfigureAwait(false);
}
else
{
- fs.CopyTo(targetStream, 81920);
+ fs.CopyTo(targetStream, StreamCopyToBufferSize);
}
}
}
@@ -352,16 +353,11 @@ namespace SocketHttpListener.Net
private static async Task CopyToInternalAsyncWithSyncRead(Stream source, Stream destination, long copyLength, CancellationToken cancellationToken)
{
- var array = new byte[81920];
+ var array = new byte[StreamCopyToBufferSize];
int bytesRead;
while ((bytesRead = source.Read(array, 0, array.Length)) != 0)
{
- if (bytesRead == 0)
- {
- break;
- }
-
var bytesToWrite = Math.Min(bytesRead, copyLength);
if (bytesToWrite > 0)
@@ -380,16 +376,11 @@ namespace SocketHttpListener.Net
private static async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength, CancellationToken cancellationToken)
{
- var array = new byte[81920];
+ var array = new byte[StreamCopyToBufferSize];
int bytesRead;
while ((bytesRead = await source.ReadAsync(array, 0, array.Length, cancellationToken).ConfigureAwait(false)) != 0)
{
- if (bytesRead == 0)
- {
- break;
- }
-
var bytesToWrite = Math.Min(bytesRead, copyLength);
if (bytesToWrite > 0)