diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-05-25 09:00:14 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-05-25 09:00:14 -0400 |
| commit | 28988b056ccc8efad54905b6f10ff0b9532c7130 (patch) | |
| tree | e5ef1b92cf28b884bb03bbfd67112a25e48a4fe7 /SocketHttpListener/Net/HttpListenerResponse.cs | |
| parent | d035d7eaec937b1ad43af6a95f723070c1e847ea (diff) | |
update stream copying
Diffstat (limited to 'SocketHttpListener/Net/HttpListenerResponse.cs')
| -rw-r--r-- | SocketHttpListener/Net/HttpListenerResponse.cs | 47 |
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) |
