aboutsummaryrefslogtreecommitdiff
path: root/SocketHttpListener.Portable
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-05-22 00:54:46 -0400
committerGitHub <noreply@github.com>2017-05-22 00:54:46 -0400
commitde1b647d97c1f85078741251a8315f0b72a0d978 (patch)
tree8d6f313fe9d71a5ecaf7a235eff4c5db6e68990b /SocketHttpListener.Portable
parent10fb7836c49654811b4621b3ce49fe40f83e7d61 (diff)
parent54cf0da75826d641b28a34afece7a4cb0eaaaec2 (diff)
Merge pull request #2656 from MediaBrowser/dev
update query fields
Diffstat (limited to 'SocketHttpListener.Portable')
-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 149b24028d..b2d0d4e9c2 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)