diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-11-28 00:42:25 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-28 00:42:25 -0500 |
| commit | f92e245dfffbc3fdf020a7fcc71faf10a9b7e305 (patch) | |
| tree | 726f0145b9fcda6c671440f2261e0222359090fd /SocketHttpListener.Portable | |
| parent | 79eabe1e5888c6866c946276a367ee5c25620763 (diff) | |
| parent | 56b24da15165ef4c4b7107b673bab5b191d76afe (diff) | |
Merge pull request #2315 from MediaBrowser/dev
Dev
Diffstat (limited to 'SocketHttpListener.Portable')
| -rw-r--r-- | SocketHttpListener.Portable/Net/HttpConnection.cs | 4 | ||||
| -rw-r--r-- | SocketHttpListener.Portable/Net/HttpListenerResponse.cs | 16 | ||||
| -rw-r--r-- | SocketHttpListener.Portable/Net/ResponseStream.cs | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/SocketHttpListener.Portable/Net/HttpConnection.cs b/SocketHttpListener.Portable/Net/HttpConnection.cs index b09d022549..4b54fc0139 100644 --- a/SocketHttpListener.Portable/Net/HttpConnection.cs +++ b/SocketHttpListener.Portable/Net/HttpConnection.cs @@ -209,7 +209,9 @@ namespace SocketHttpListener.Net // TODO: can we get this stream before reading the input? if (o_stream == null) { - if (context.Response.SendChunked || isExpect100Continue || context.Response.ContentLength64 <= 0) + context.Response.DetermineIfChunked(); + + if (context.Response.SendChunked || isExpect100Continue || context.Request.IsWebSocketRequest) { o_stream = new ResponseStream(stream, context.Response, _memoryStreamFactory, _textEncoding); } diff --git a/SocketHttpListener.Portable/Net/HttpListenerResponse.cs b/SocketHttpListener.Portable/Net/HttpListenerResponse.cs index 880473c0a2..c1182de343 100644 --- a/SocketHttpListener.Portable/Net/HttpListenerResponse.cs +++ b/SocketHttpListener.Portable/Net/HttpListenerResponse.cs @@ -362,6 +362,22 @@ namespace SocketHttpListener.Net return false; } + public void DetermineIfChunked() + { + if (chunked) + { + return ; + } + + Version v = context.Request.ProtocolVersion; + if (!cl_set && !chunked && v >= HttpVersion.Version11) + chunked = true; + if (!chunked && string.Equals(headers["Transfer-Encoding"], "chunked")) + { + chunked = true; + } + } + internal void SendHeaders(bool closing, MemoryStream ms) { Encoding encoding = content_encoding; diff --git a/SocketHttpListener.Portable/Net/ResponseStream.cs b/SocketHttpListener.Portable/Net/ResponseStream.cs index 7a6425deac..6067a89ec6 100644 --- a/SocketHttpListener.Portable/Net/ResponseStream.cs +++ b/SocketHttpListener.Portable/Net/ResponseStream.cs @@ -14,7 +14,7 @@ namespace SocketHttpListener.Net // Update: we send a single packet for the first non-chunked Write // What happens when we set content-length to X and write X-1 bytes then close? // what if we don't set content-length at all? - class ResponseStream : Stream + public class ResponseStream : Stream { HttpListenerResponse response; bool disposed; |
