diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs
index 78b883d341..41ef15bc96 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs
@@ -43,13 +43,46 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// System.Object.
public object GetResult(object content, string contentType, IDictionary responseHeaders = null)
{
- var result = new HttpResult(content, contentType);
+ return GetHttpResult(content, contentType, responseHeaders);
+ }
+
+ ///
+ /// Gets the HTTP result.
+ ///
+ /// The content.
+ /// Type of the content.
+ /// The response headers.
+ /// IHasOptions.
+ private IHasOptions GetHttpResult(object content, string contentType, IDictionary responseHeaders = null)
+ {
+ IHasOptions result;
+
+ var stream = content as Stream;
+
+ if (stream != null)
+ {
+ result = new StreamWriter(stream, contentType, _logger);
+ }
+
+ else
+ {
+ var bytes = content as byte[];
+
+ if (bytes != null)
+ {
+ result = new StreamWriter(bytes, contentType, _logger);
+ }
+ else
+ {
+ result = new HttpResult(content, contentType);
+ }
+ }
if (responseHeaders != null)
{
AddResponseHeaders(result, responseHeaders);
}
-
+
return result;
}
@@ -376,7 +409,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (isHeadRequest)
{
- return new HttpResult(new byte[] { }, contentType);
+ return GetHttpResult(new byte[] { }, contentType);
}
return new StreamWriter(stream, contentType, _logger);
@@ -384,7 +417,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (isHeadRequest)
{
- return new HttpResult(new byte[] { }, contentType);
+ return GetHttpResult(new byte[] { }, contentType);
}
string content;
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
index d22605cb3f..2570ca5bdb 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs
@@ -1,3 +1,16 @@
+// ***********************************************************************
+// Assembly : MediaBrowser.Server.Implementations
+// Author : Luke
+// Created : 03-06-2013
+//
+// Last Modified By : Luke
+// Last Modified On : 03-24-2013
+// ***********************************************************************
+//
+// Copyright (c) . All rights reserved.
+//
+//
+// ***********************************************************************
using Funq;
using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
@@ -47,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
///
/// The _rest services
///
- private readonly List _restServices = new List();
+ private readonly List _restServices = new List();
///
/// Gets or sets the application host.
@@ -66,7 +79,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
///
/// The protobuf serializer.
private IProtobufSerializer ProtobufSerializer { get; set; }
-
+
///
/// Occurs when [web socket connected].
///
@@ -208,6 +221,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// Format should be: http://127.0.0.1:8080/ or http://127.0.0.1:8080/somevirtual/
/// Note: the trailing slash is required! For more info see the
/// HttpListener.Prefixes property on MSDN.
+ /// urlBase
public override void Start(string urlBase)
{
if (string.IsNullOrEmpty(urlBase))
@@ -457,6 +471,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// Logs the response.
///
/// The CTX.
+ /// The URL.
+ /// The end point.
private void LogResponse(HttpListenerContext ctx, string url, IPEndPoint endPoint)
{
if (!EnableHttpRequestLogging)
@@ -554,9 +570,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
_restServices.AddRange(services);
+ _logger.Info("Calling EndpointHost.ConfigureHost");
EndpointHost.ConfigureHost(this, ServerName, CreateServiceManager());
+
+ _logger.Info("Registering protobuf as a content type filter");
ContentTypeFilters.Register(ContentType.ProtoBuf, (reqCtx, res, stream) => ProtobufSerializer.SerializeToStream(res, stream), (type, stream) => ProtobufSerializer.DeserializeFromStream(stream, type));
+ _logger.Info("Calling ServiceStack AppHost.Init");
Init();
}
}
diff --git a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs
index da84a51cdc..46d38ad148 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/StreamWriter.cs
@@ -19,7 +19,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// Gets or sets the source stream.
///
/// The source stream.
- public Stream SourceStream { get; set; }
+ private Stream SourceStream { get; set; }
///
/// The _options
@@ -53,6 +53,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer
Options["Content-Type"] = contentType;
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The source.
+ /// Type of the content.
+ /// The logger.
+ public StreamWriter(byte[] source, string contentType, ILogger logger)
+ : this(new MemoryStream(source), contentType, logger)
+ {
+ }
+
///
/// Writes to.
///
diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
index 119a045cdb..cba74ffbf8 100644
--- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
+++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs
@@ -153,6 +153,7 @@ namespace MediaBrowser.Server.Implementations.ServerManager
}
ReloadUdpServer();
+
ReloadHttpServer();
if (!SupportsNativeWebSocket)
@@ -268,6 +269,9 @@ namespace MediaBrowser.Server.Implementations.ServerManager
{
// The port number can't be in configuration because we don't want it to ever change
UdpServer = _applicationHost.Resolve();
+
+ _logger.Info("Starting udp server");
+
UdpServer.Start(_kernel.UdpServerPortNumber);
}
catch (SocketException ex)
@@ -428,6 +432,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager
///
private void RegisterServerWithAdministratorAccess()
{
+ _logger.Info("Requesting administrative access to authorize http server");
+
// Create a temp file path to extract the bat file to
var tmpFile = Path.Combine(ConfigurationManager.CommonApplicationPaths.TempDirectory, Guid.NewGuid() + ".bat");