aboutsummaryrefslogtreecommitdiff
path: root/SocketHttpListener/Net/HttpListenerResponse.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-05-25 09:00:55 -0400
committerGitHub <noreply@github.com>2017-05-25 09:00:55 -0400
commit40bc3b7b2205d7bc0802cf81bf199c655b81efd7 (patch)
treece7efa462a2620c3d2eddeaec41464ac3959f50c /SocketHttpListener/Net/HttpListenerResponse.cs
parent2715db6ad794588614a2585a51d1cfde6d8e2941 (diff)
parentb527e56ec3b7d644245b2a2b6bd39c1e2a375c83 (diff)
Merge pull request #2664 from MediaBrowser/dev
Dev
Diffstat (limited to 'SocketHttpListener/Net/HttpListenerResponse.cs')
-rw-r--r--SocketHttpListener/Net/HttpListenerResponse.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/SocketHttpListener/Net/HttpListenerResponse.cs b/SocketHttpListener/Net/HttpListenerResponse.cs
index 185454ef6..da7aff081 100644
--- a/SocketHttpListener/Net/HttpListenerResponse.cs
+++ b/SocketHttpListener/Net/HttpListenerResponse.cs
@@ -53,6 +53,11 @@ namespace SocketHttpListener.Net
}
}
+ public bool ForceCloseChunked
+ {
+ get { return false; }
+ }
+
public Encoding ContentEncoding
{
get
@@ -335,6 +340,48 @@ namespace SocketHttpListener.Net
context.Connection.Close(force);
}
+ public void Close(byte[] responseEntity, bool willBlock)
+ {
+ //CheckDisposed();
+
+ if (responseEntity == null)
+ {
+ throw new ArgumentNullException(nameof(responseEntity));
+ }
+
+ //if (_boundaryType != BoundaryType.Chunked)
+ {
+ ContentLength64 = responseEntity.Length;
+ }
+
+ if (willBlock)
+ {
+ try
+ {
+ OutputStream.Write(responseEntity, 0, responseEntity.Length);
+ }
+ finally
+ {
+ Close(false);
+ }
+ }
+ else
+ {
+ OutputStream.BeginWrite(responseEntity, 0, responseEntity.Length, iar =>
+ {
+ var thisRef = (HttpListenerResponse)iar.AsyncState;
+ try
+ {
+ thisRef.OutputStream.EndWrite(iar);
+ }
+ finally
+ {
+ thisRef.Close(false);
+ }
+ }, this);
+ }
+ }
+
public void Close()
{
if (disposed)