From 102bbe2beb76fa76b21f4ed3f7c584a58d787204 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 12 Nov 2016 17:46:38 -0500 Subject: [PATCH] fix mono project --- .../MediaBrowser.Server.Mono.csproj | 44 +++++++++++++++++++ ServiceStack/Host/RestHandler.cs | 36 +++------------ ServiceStack/ServiceStackHost.Runtime.cs | 21 +-------- .../Net/HttpConnection.cs | 6 +-- .../Net/HttpListenerRequest.cs | 13 ++++-- .../Net/HttpListenerResponse.cs | 4 +- 6 files changed, 66 insertions(+), 58 deletions(-) diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj index 090e8ea9a..ca830b2f4 100644 --- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj +++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj @@ -115,6 +115,34 @@ + + {88ae38df-19d7-406f-a6a9-09527719a21e} + BDInfo + + + {713f42b5-878e-499d-a878-e4c652b1d5e8} + DvdLib + + + {805844ab-e92f-45e6-9d99-4f6d48d129a5} + Emby.Dlna + + + {6cfee013-6e7c-432b-ac37-cabf0880c69a} + Emby.Drawing.ImageMagick + + + {c97a239e-a96c-4d64-a844-ccf8cc30aecb} + Emby.Drawing.Net + + + {08fff49b-f175-4807-a2b5-73b0ebd9f716} + Emby.Drawing + + + {89ab4548-770d-41fd-a891-8daff44f452c} + Emby.Photos + {e383961b-9356-4d5d-8233-9a1079d03055} Emby.Server.Implementations @@ -163,6 +191,22 @@ {23499896-B135-4527-8574-C26E926EA99E} MediaBrowser.XbmcMetadata + + {4a4402d4-e910-443b-b8fc-2c18286a2ca0} + OpenSubtitlesHandler + + + {21002819-c39a-4d3e-be83-2a276a77fb1f} + RSSDP + + + {680a1709-25eb-4d52-a87f-ee03ffd94baa} + ServiceStack + + + {4f26d5d8-a7b0-42b3-ba42-7cb7d245934e} + SocketHttpListener.Portable + diff --git a/ServiceStack/Host/RestHandler.cs b/ServiceStack/Host/RestHandler.cs index 5c360d150..1eae6be38 100644 --- a/ServiceStack/Host/RestHandler.cs +++ b/ServiceStack/Host/RestHandler.cs @@ -23,32 +23,13 @@ namespace ServiceStack.Host var taskResult = ServiceStackHost.Instance.GetTaskResult(taskResponse, RequestName); - var taskResults = taskResult as Task[]; - - if (taskResults == null) + var subTask = taskResult as Task; + if (subTask != null) { - var subTask = taskResult as Task; - if (subTask != null) - taskResult = ServiceStackHost.Instance.GetTaskResult(subTask, RequestName); - - return taskResult; + taskResult = ServiceStackHost.Instance.GetTaskResult(subTask, RequestName); } - if (taskResults.Length == 0) - { - return new object[] { }; - } - - var firstResponse = ServiceStackHost.Instance.GetTaskResult(taskResults[0], RequestName); - var batchedResponses = firstResponse != null - ? (object[])Array.CreateInstance(firstResponse.GetType(), taskResults.Length) - : new object[taskResults.Length]; - batchedResponses[0] = firstResponse; - for (var i = 1; i < taskResults.Length; i++) - { - batchedResponses[i] = ServiceStackHost.Instance.GetTaskResult(taskResults[i], RequestName); - } - return batchedResponses; + return taskResult; } protected static object CreateContentTypeRequest(IRequest httpReq, Type requestType, string contentType) @@ -141,18 +122,13 @@ namespace ServiceStack.Host var request = httpReq.Dto = CreateRequest(httpReq, restPath); - if (appHost.ApplyRequestFilters(httpReq, httpRes, request)) - return; + appHost.ApplyRequestFilters(httpReq, httpRes, request); var rawResponse = await ServiceStackHost.Instance.ServiceController.Execute(request, httpReq).ConfigureAwait(false); - if (httpRes.IsClosed) - return; - var response = await HandleResponseAsync(rawResponse).ConfigureAwait(false); - if (appHost.ApplyResponseFilters(httpReq, httpRes, response)) - return; + appHost.ApplyResponseFilters(httpReq, httpRes, response); await httpRes.WriteToResponse(httpReq, response).ConfigureAwait(false); } diff --git a/ServiceStack/ServiceStackHost.Runtime.cs b/ServiceStack/ServiceStackHost.Runtime.cs index 1a1656a0e..aaa50633b 100644 --- a/ServiceStack/ServiceStackHost.Runtime.cs +++ b/ServiceStack/ServiceStackHost.Runtime.cs @@ -14,10 +14,8 @@ namespace ServiceStack /// and no more processing should be done. /// /// - public virtual bool ApplyRequestFilters(IRequest req, IResponse res, object requestDto) + public virtual void ApplyRequestFilters(IRequest req, IResponse res, object requestDto) { - if (res.IsClosed) return res.IsClosed; - //Exec all RequestFilter attributes with Priority < 0 var attributes = FilterAttributeCache.GetRequestFilterAttributes(requestDto.GetType()); var i = 0; @@ -25,16 +23,12 @@ namespace ServiceStack { var attribute = attributes[i]; attribute.RequestFilter(req, res, requestDto); - if (res.IsClosed) return res.IsClosed; } - if (res.IsClosed) return res.IsClosed; - //Exec global filters foreach (var requestFilter in GlobalRequestFilters) { requestFilter(req, res, requestDto); - if (res.IsClosed) return res.IsClosed; } //Exec remaining RequestFilter attributes with Priority >= 0 @@ -42,10 +36,7 @@ namespace ServiceStack { var attribute = attributes[i]; attribute.RequestFilter(req, res, requestDto); - if (res.IsClosed) return res.IsClosed; } - - return res.IsClosed; } /// @@ -53,21 +44,13 @@ namespace ServiceStack /// and no more processing should be done. /// /// - public virtual bool ApplyResponseFilters(IRequest req, IResponse res, object response) + public virtual void ApplyResponseFilters(IRequest req, IResponse res, object response) { - if (response != null) - { - if (res.IsClosed) return res.IsClosed; - } - //Exec global filters foreach (var responseFilter in GlobalResponseFilters) { responseFilter(req, res, response); - if (res.IsClosed) return res.IsClosed; } - - return res.IsClosed; } } diff --git a/SocketHttpListener.Portable/Net/HttpConnection.cs b/SocketHttpListener.Portable/Net/HttpConnection.cs index 8e472117e..67dd5c958 100644 --- a/SocketHttpListener.Portable/Net/HttpConnection.cs +++ b/SocketHttpListener.Portable/Net/HttpConnection.cs @@ -204,12 +204,12 @@ namespace SocketHttpListener.Net return i_stream; } - public Stream GetResponseStream() + public Stream GetResponseStream(HttpListenerRequest request) { // TODO: can we get this stream before reading the input? if (o_stream == null) { - if (context.Response.SendChunked) + if (context.Response.SendChunked || request == null || request.HasExpect100Continue) { o_stream = new ResponseStream(stream, context.Response, _memoryStreamFactory, _textEncoding); } @@ -490,7 +490,7 @@ namespace SocketHttpListener.Net { if (!context.Request.IsWebSocketRequest || force_close) { - Stream st = GetResponseStream(); + Stream st = GetResponseStream(context.Request); if (st != null) st.Dispose(); diff --git a/SocketHttpListener.Portable/Net/HttpListenerRequest.cs b/SocketHttpListener.Portable/Net/HttpListenerRequest.cs index 5631fc0a1..767f1c542 100644 --- a/SocketHttpListener.Portable/Net/HttpListenerRequest.cs +++ b/SocketHttpListener.Portable/Net/HttpListenerRequest.cs @@ -179,16 +179,21 @@ namespace SocketHttpListener.Net } } - if (String.Compare(Headers["Expect"], "100-continue", StringComparison.OrdinalIgnoreCase) == 0) + if (HasExpect100Continue) { - var output = context.Connection.GetResponseStream(); - + var output = (ResponseStream)context.Connection.GetResponseStream(this); + var _100continue = _textEncoding.GetASCIIEncoding().GetBytes("HTTP/1.1 100 Continue\r\n\r\n"); - //output.InternalWrite(_100continue, 0, _100continue.Length); + output.InternalWrite(_100continue, 0, _100continue.Length); } } + public bool HasExpect100Continue + { + get { return String.Compare(Headers["Expect"], "100-continue", StringComparison.OrdinalIgnoreCase) == 0; } + } + static bool MaybeUri(string s) { int p = s.IndexOf(':'); diff --git a/SocketHttpListener.Portable/Net/HttpListenerResponse.cs b/SocketHttpListener.Portable/Net/HttpListenerResponse.cs index 93358cae4..8c610d725 100644 --- a/SocketHttpListener.Portable/Net/HttpListenerResponse.cs +++ b/SocketHttpListener.Portable/Net/HttpListenerResponse.cs @@ -149,7 +149,7 @@ namespace SocketHttpListener.Net get { if (output_stream == null) - output_stream = context.Connection.GetResponseStream(); + output_stream = context.Connection.GetResponseStream(context.Request); return output_stream; } } @@ -489,7 +489,7 @@ namespace SocketHttpListener.Net int preamble = encoding.GetPreamble().Length; if (output_stream == null) - output_stream = context.Connection.GetResponseStream(); + output_stream = context.Connection.GetResponseStream(context.Request); /* Assumes that the ms was at position 0 */ ms.Position = preamble;