aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Services
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-05-26 12:25:43 -0400
committerGitHub <noreply@github.com>2017-05-26 12:25:43 -0400
commit84077e824df3bda4f74e12b961d4e962b0e04a42 (patch)
treeb2df17cd1648ef4c6fe16610abce2e04af8dfa7e /Emby.Server.Implementations/Services
parent40bc3b7b2205d7bc0802cf81bf199c655b81efd7 (diff)
parent89ba154522ed12f7ba64cc8190843f20795c728e (diff)
Merge pull request #2666 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Services')
-rw-r--r--Emby.Server.Implementations/Services/ResponseHelper.cs29
-rw-r--r--Emby.Server.Implementations/Services/ServiceController.cs6
-rw-r--r--Emby.Server.Implementations/Services/ServiceHandler.cs3
3 files changed, 13 insertions, 25 deletions
diff --git a/Emby.Server.Implementations/Services/ResponseHelper.cs b/Emby.Server.Implementations/Services/ResponseHelper.cs
index 22d2b95f7..84dc343c3 100644
--- a/Emby.Server.Implementations/Services/ResponseHelper.cs
+++ b/Emby.Server.Implementations/Services/ResponseHelper.cs
@@ -12,39 +12,28 @@ namespace Emby.Server.Implementations.Services
{
public static class ResponseHelper
{
- public static Task WriteToResponse(IResponse httpRes, IRequest httpReq, object result, CancellationToken cancellationToken)
+ public static async Task WriteToResponse(IResponse response, IRequest request, object result, CancellationToken cancellationToken)
{
if (result == null)
{
- if (httpRes.StatusCode == (int)HttpStatusCode.OK)
+ if (response.StatusCode == (int)HttpStatusCode.OK)
{
- httpRes.StatusCode = (int)HttpStatusCode.NoContent;
+ response.StatusCode = (int)HttpStatusCode.NoContent;
}
- httpRes.SetContentLength(0);
- return Task.FromResult(true);
+ response.SetContentLength(0);
+ return;
}
var httpResult = result as IHttpResult;
if (httpResult != null)
{
- httpResult.RequestContext = httpReq;
- httpReq.ResponseContentType = httpResult.ContentType ?? httpReq.ResponseContentType;
- return WriteToResponseInternal(httpRes, httpResult, httpReq, cancellationToken);
+ httpResult.RequestContext = request;
+ request.ResponseContentType = httpResult.ContentType ?? request.ResponseContentType;
}
- return WriteToResponseInternal(httpRes, result, httpReq, cancellationToken);
- }
-
- /// <summary>
- /// Writes to response.
- /// Response headers are customizable by implementing IHasHeaders an returning Dictionary of Http headers.
- /// </summary>
- private static async Task WriteToResponseInternal(IResponse response, object result, IRequest request, CancellationToken cancellationToken)
- {
var defaultContentType = request.ResponseContentType;
- var httpResult = result as IHttpResult;
if (httpResult != null)
{
if (httpResult.RequestContext == null)
@@ -135,7 +124,7 @@ namespace Emby.Server.Implementations.Services
response.ContentType = "application/octet-stream";
response.SetContentLength(bytes.Length);
- await response.OutputStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
+ await response.OutputStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken).ConfigureAwait(false);
return;
}
@@ -144,7 +133,7 @@ namespace Emby.Server.Implementations.Services
{
bytes = Encoding.UTF8.GetBytes(responseText);
response.SetContentLength(bytes.Length);
- await response.OutputStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
+ await response.OutputStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken).ConfigureAwait(false);
return;
}
diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs
index d283bf81f..1c530144c 100644
--- a/Emby.Server.Implementations/Services/ServiceController.cs
+++ b/Emby.Server.Implementations/Services/ServiceController.cs
@@ -187,7 +187,7 @@ namespace Emby.Server.Implementations.Services
return null;
}
- public async Task<object> Execute(HttpListenerHost appHost, object requestDto, IRequest req)
+ public Task<object> Execute(HttpListenerHost appHost, object requestDto, IRequest req)
{
req.Dto = requestDto;
var requestType = requestDto.GetType();
@@ -209,9 +209,7 @@ namespace Emby.Server.Implementations.Services
req.Dto = requestDto;
//Executes the service and returns the result
- var response = await ServiceExecGeneral.Execute(serviceType, req, service, requestDto, requestType.GetMethodName()).ConfigureAwait(false);
-
- return response;
+ return ServiceExecGeneral.Execute(serviceType, req, service, requestDto, requestType.GetMethodName());
}
}
diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs
index 95a9dd682..526e62d39 100644
--- a/Emby.Server.Implementations/Services/ServiceHandler.cs
+++ b/Emby.Server.Implementations/Services/ServiceHandler.cs
@@ -143,7 +143,8 @@ namespace Emby.Server.Implementations.Services
var rawResponse = await appHost.ServiceController.Execute(appHost, request, httpReq).ConfigureAwait(false);
- var response = await HandleResponseAsync(rawResponse).ConfigureAwait(false);
+ //var response = await HandleResponseAsync(rawResponse).ConfigureAwait(false);
+ var response = rawResponse;
// Apply response filters
foreach (var responseFilter in appHost.ResponseFilters)