diff options
Diffstat (limited to 'SocketHttpListener.Portable/Net')
| -rw-r--r-- | SocketHttpListener.Portable/Net/HttpConnection.cs | 4 | ||||
| -rw-r--r-- | SocketHttpListener.Portable/Net/HttpListenerResponse.cs | 7 | ||||
| -rw-r--r-- | SocketHttpListener.Portable/Net/ResponseStream.cs | 12 |
3 files changed, 17 insertions, 6 deletions
diff --git a/SocketHttpListener.Portable/Net/HttpConnection.cs b/SocketHttpListener.Portable/Net/HttpConnection.cs index bc4286dc8..3baffd258 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) { - context.Response.DetermineIfChunked(); + //context.Response.DetermineIfChunked(); if (context.Response.SendChunked || isExpect100Continue || context.Request.IsWebSocketRequest || true) { @@ -508,7 +508,7 @@ namespace SocketHttpListener.Net { force_close |= !context.Request.KeepAlive; if (!force_close) - force_close = (context.Response.Headers["connection"] == "close"); + force_close = (string.Equals(context.Response.Headers["connection"], "close", StringComparison.OrdinalIgnoreCase)); /* if (!force_close) { // bool conn_close = (status_code == 400 || status_code == 408 || status_code == 411 || diff --git a/SocketHttpListener.Portable/Net/HttpListenerResponse.cs b/SocketHttpListener.Portable/Net/HttpListenerResponse.cs index c1182de34..9a5862cb9 100644 --- a/SocketHttpListener.Portable/Net/HttpListenerResponse.cs +++ b/SocketHttpListener.Portable/Net/HttpListenerResponse.cs @@ -386,7 +386,7 @@ namespace SocketHttpListener.Net if (content_type != null) { - if (content_encoding != null && content_type.IndexOf("charset=", StringComparison.Ordinal) == -1) + if (content_encoding != null && content_type.IndexOf("charset=", StringComparison.OrdinalIgnoreCase) == -1) { string enc_name = content_encoding.WebName; headers.SetInternal("Content-Type", content_type + "; charset=" + enc_name); @@ -429,9 +429,10 @@ namespace SocketHttpListener.Net * HttpStatusCode.InternalServerError 500 * HttpStatusCode.ServiceUnavailable 503 */ - bool conn_close = (status_code == 408 || status_code == 411 || + bool conn_close = status_code == 400 || status_code == 408 || status_code == 411 || status_code == 413 || status_code == 414 || - status_code == 503); + status_code == 500 || + status_code == 503; if (conn_close == false) conn_close = !context.Request.KeepAlive; diff --git a/SocketHttpListener.Portable/Net/ResponseStream.cs b/SocketHttpListener.Portable/Net/ResponseStream.cs index 6067a89ec..a79a18791 100644 --- a/SocketHttpListener.Portable/Net/ResponseStream.cs +++ b/SocketHttpListener.Portable/Net/ResponseStream.cs @@ -136,6 +136,11 @@ namespace SocketHttpListener.Net if (disposed) throw new ObjectDisposedException(GetType().ToString()); + if (count == 0) + { + //return; + } + byte[] bytes = null; MemoryStream ms = GetHeaders(response, _memoryStreamFactory, false); bool chunked = response.SendChunked; @@ -176,6 +181,11 @@ namespace SocketHttpListener.Net if (disposed) throw new ObjectDisposedException(GetType().ToString()); + if (count == 0) + { + //return; + } + byte[] bytes = null; MemoryStream ms = GetHeaders(response, _memoryStreamFactory, false); bool chunked = response.SendChunked; @@ -206,7 +216,7 @@ namespace SocketHttpListener.Net await stream.WriteAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false); } - if (response.SendChunked) + if (chunked) stream.Write(crlf, 0, 2); } |
