diff options
| author | Andrew Rabert <6550543+nvllsvm@users.noreply.github.com> | 2019-01-22 18:13:47 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-22 18:13:47 -0500 |
| commit | 28483bdb54be96ae83e0fded097f534d7e26ba1e (patch) | |
| tree | e7f4b92326417ebf55eecdf68a01d2c3b9e660d7 /SocketHttpListener/Net/HttpListenerResponse.Managed.cs | |
| parent | 920c39454c05e979eabe81877269cd4517a03ccf (diff) | |
| parent | 8106c8393b711a7e1d40487e3caf2b014decbe28 (diff) | |
Merge pull request #651 from jellyfin/release-10.1.0
Release 10.1.0
Diffstat (limited to 'SocketHttpListener/Net/HttpListenerResponse.Managed.cs')
| -rw-r--r-- | SocketHttpListener/Net/HttpListenerResponse.Managed.cs | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs index 34953b569..f595fce7c 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; using System.Globalization; using System.IO; using System.Net; using System.Text; -using System.Threading.Tasks; -using MediaBrowser.Model.Text; -using SocketHttpListener.Primitives; using System.Threading; +using System.Threading.Tasks; using MediaBrowser.Model.IO; namespace SocketHttpListener.Net @@ -19,12 +16,10 @@ namespace SocketHttpListener.Net private int _statusCode = 200; internal object _headersLock = new object(); private bool _forceCloseChunked; - private ITextEncoding _textEncoding; - internal HttpListenerResponse(HttpListenerContext context, ITextEncoding textEncoding) + internal HttpListenerResponse(HttpListenerContext context) { _httpContext = context; - _textEncoding = textEncoding; } internal bool ForceCloseChunked => _forceCloseChunked; @@ -39,7 +34,7 @@ namespace SocketHttpListener.Net public Version ProtocolVersion { - get { return _version; } + get => _version; set { CheckDisposed(); @@ -58,7 +53,7 @@ namespace SocketHttpListener.Net public int StatusCode { - get { return _statusCode; } + get => _statusCode; set { CheckDisposed(); @@ -207,13 +202,13 @@ namespace SocketHttpListener.Net } /* Apache forces closing the connection for these status codes: - * HttpStatusCode.BadRequest 400 - * HttpStatusCode.RequestTimeout 408 - * HttpStatusCode.LengthRequired 411 - * HttpStatusCode.RequestEntityTooLarge 413 - * HttpStatusCode.RequestUriTooLong 414 - * HttpStatusCode.InternalServerError 500 - * HttpStatusCode.ServiceUnavailable 503 + * HttpStatusCode.BadRequest 400 + * HttpStatusCode.RequestTimeout 408 + * HttpStatusCode.LengthRequired 411 + * HttpStatusCode.RequestEntityTooLarge 413 + * HttpStatusCode.RequestUriTooLong 414 + * HttpStatusCode.InternalServerError 500 + * HttpStatusCode.ServiceUnavailable 503 */ bool conn_close = (_statusCode == (int)HttpStatusCode.BadRequest || _statusCode == (int)HttpStatusCode.RequestTimeout || _statusCode == (int)HttpStatusCode.LengthRequired || _statusCode == (int)HttpStatusCode.RequestEntityTooLarge @@ -264,8 +259,8 @@ namespace SocketHttpListener.Net ComputeCookies(); } - Encoding encoding = _textEncoding.GetDefaultEncoding(); - StreamWriter writer = new StreamWriter(ms, encoding, 256); + var encoding = Encoding.UTF8; + var writer = new StreamWriter(ms, encoding, 256); writer.Write("HTTP/1.1 {0} ", _statusCode); // "1.1" matches Windows implementation, which ignores the response version writer.Flush(); byte[] statusDescriptionBytes = WebHeaderEncoding.GetBytes(StatusDescription); |
