From 3e06bda46b2569c1df47d9ab0c7a763dcf3b1451 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 12 Nov 2016 20:53:51 -0500 Subject: update components --- SocketHttpListener.Portable/Net/HttpConnection.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'SocketHttpListener.Portable/Net/HttpConnection.cs') diff --git a/SocketHttpListener.Portable/Net/HttpConnection.cs b/SocketHttpListener.Portable/Net/HttpConnection.cs index d9fd97ed2..b09d02254 100644 --- a/SocketHttpListener.Portable/Net/HttpConnection.cs +++ b/SocketHttpListener.Portable/Net/HttpConnection.cs @@ -209,7 +209,7 @@ namespace SocketHttpListener.Net // TODO: can we get this stream before reading the input? if (o_stream == null) { - if (context.Response.SendChunked || isExpect100Continue) + if (context.Response.SendChunked || isExpect100Continue || context.Response.ContentLength64 <= 0) { o_stream = new ResponseStream(stream, context.Response, _memoryStreamFactory, _textEncoding); } @@ -438,7 +438,9 @@ namespace SocketHttpListener.Net str = String.Format("

{0}

", description); byte[] error = context.Response.ContentEncoding.GetBytes(str); - response.Close(error, false); + response.ContentLength64 = error.Length; + response.OutputStream.Write(error, 0, (int)error.Length); + response.Close(); } catch { @@ -492,7 +494,9 @@ namespace SocketHttpListener.Net { Stream st = GetResponseStream(); if (st != null) + { st.Dispose(); + } o_stream = null; } @@ -514,16 +518,6 @@ namespace SocketHttpListener.Net if (!force_close && context.Request.FlushInput()) { - if (chunked && context.Response.ForceCloseChunked == false) - { - // Don't close. Keep working. - reuses++; - Unbind(); - Init(); - BeginReadRequest(); - return; - } - reuses++; Unbind(); Init(); -- cgit v1.2.3