diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index 49c664eeca..41b7a4622e 100644
--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Text;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
using Emby.Server.Implementations.HttpServer.SocketSharp;
@@ -248,9 +249,7 @@ namespace Emby.Server.Implementations.HttpServer
httpRes.StatusCode = statusCode;
httpRes.ContentType = "text/html";
- httpRes.Write(ex.Message);
-
- httpRes.Close();
+ Write(httpRes, ex.Message);
}
catch
{
@@ -404,7 +403,7 @@ namespace Emby.Server.Implementations.HttpServer
{
httpRes.StatusCode = 400;
httpRes.ContentType = "text/plain";
- httpRes.Write("Invalid host");
+ Write(httpRes, "Invalid host");
return;
}
@@ -458,7 +457,7 @@ namespace Emby.Server.Implementations.HttpServer
if (!string.Equals(newUrl, urlString, StringComparison.OrdinalIgnoreCase))
{
- httpRes.Write(
+ Write(httpRes,
"
EmbyPlease update your Emby bookmark to " + newUrl + "");
return;
@@ -475,7 +474,7 @@ namespace Emby.Server.Implementations.HttpServer
if (!string.Equals(newUrl, urlString, StringComparison.OrdinalIgnoreCase))
{
- httpRes.Write(
+ Write(httpRes,
"EmbyPlease update your Emby bookmark to " + newUrl + "");
return;
@@ -513,7 +512,7 @@ namespace Emby.Server.Implementations.HttpServer
{
httpRes.StatusCode = 503;
httpRes.ContentType = "text/html";
- httpRes.Write(GlobalResponse);
+ Write(httpRes, GlobalResponse);
return;
}
@@ -547,6 +546,15 @@ namespace Emby.Server.Implementations.HttpServer
}
}
+ private void Write(IResponse response, string text)
+ {
+ var bOutput = Encoding.UTF8.GetBytes(text);
+ response.SetContentLength(bOutput.Length);
+
+ var outputStream = response.OutputStream;
+ outputStream.Write(bOutput, 0, bOutput.Length);
+ }
+
public static void RedirectToUrl(IResponse httpRes, string url)
{
httpRes.StatusCode = 302;
diff --git a/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs b/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs
index 9de86e9cc1..a8b1150567 100644
--- a/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs
+++ b/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs
@@ -77,16 +77,6 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
get { return _response.OutputStream; }
}
- public void Write(string text)
- {
- var bOutput = System.Text.Encoding.UTF8.GetBytes(text);
- _response.ContentLength64 = bOutput.Length;
-
- var outputStream = _response.OutputStream;
- outputStream.Write(bOutput, 0, bOutput.Length);
- Close();
- }
-
public void Close()
{
if (!this.IsClosed)
@@ -108,8 +98,10 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
{
try
{
- response.OutputStream.Flush();
- response.OutputStream.Dispose();
+ var outputStream = response.OutputStream;
+
+ outputStream.Flush();
+ outputStream.Dispose();
response.Close();
}
catch (Exception ex)
@@ -118,11 +110,6 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
}
}
- public void Flush()
- {
- _response.OutputStream.Flush();
- }
-
public bool IsClosed
{
get;
diff --git a/MediaBrowser.Model/Services/IRequest.cs b/MediaBrowser.Model/Services/IRequest.cs
index 455a69d372..e9a9f1c5b5 100644
--- a/MediaBrowser.Model/Services/IRequest.cs
+++ b/MediaBrowser.Model/Services/IRequest.cs
@@ -136,23 +136,12 @@ namespace MediaBrowser.Model.Services
Stream OutputStream { get; }
- ///
- /// Write once to the Response Stream then close it.
- ///
- ///
- void Write(string text);
-
///
/// Signal that this response has been handled and no more processing should be done.
/// When used in a request or response filter, no more filters or processing is done on this request.
///
void Close();
- ///
- /// Response.Flush() and OutputStream.Flush() seem to have different behaviour in ASP.NET
- ///
- void Flush();
-
///
/// Gets a value indicating whether this instance is closed.
///
@@ -160,8 +149,6 @@ namespace MediaBrowser.Model.Services
void SetContentLength(long contentLength);
- bool KeepAlive { get; set; }
-
//Add Metadata to Response
Dictionary Items { get; }
}
diff --git a/ServiceStack/Host/ContentTypes.cs b/ServiceStack/Host/ContentTypes.cs
index 58ba29801d..8840e7c8b8 100644
--- a/ServiceStack/Host/ContentTypes.cs
+++ b/ServiceStack/Host/ContentTypes.cs
@@ -18,15 +18,7 @@ namespace ServiceStack.Host
serializer(response, responseStream);
}
- public Action