From 48d1e2b85b8aba122b49c5b543526b5cfabb6ee3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 17 Sep 2017 01:25:55 -0400 Subject: [PATCH] flush before socket transfer --- .../Net/HttpResponseStream.Managed.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs index 7e175f8d6..2de3fbb94 100644 --- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs +++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs @@ -285,16 +285,11 @@ namespace SocketHttpListener.Net } } - private bool EnableSendFileWithSocket = false; - public Task TransmitFile(string path, long offset, long count, FileShareMode fileShareMode, CancellationToken cancellationToken) { - //if (_supportsDirectSocketAccess && offset == 0 && count == 0 && !_response.SendChunked && _response.ContentLength64 > 8192) + //if (_supportsDirectSocketAccess && offset == 0 && count == 0 && !_response.SendChunked) //{ - // if (EnableSendFileWithSocket) - // { - // return TransmitFileOverSocket(path, offset, count, fileShareMode, cancellationToken); - // } + // return TransmitFileOverSocket(path, offset, count, fileShareMode, cancellationToken); //} return TransmitFileManaged(path, offset, count, fileShareMode, cancellationToken); @@ -319,7 +314,9 @@ namespace SocketHttpListener.Net return TransmitFileManaged(path, offset, count, fileShareMode, cancellationToken); } - //_logger.Info("Socket sending file {0} {1}", path, response.ContentLength64); + _stream.Flush(); + + _logger.Info("Socket sending file {0}", path); var taskCompletion = new TaskCompletionSource();