diff options
Diffstat (limited to 'Emby.Server.Implementations/Services')
| -rw-r--r-- | Emby.Server.Implementations/Services/ResponseHelper.cs | 16 | ||||
| -rw-r--r-- | Emby.Server.Implementations/Services/ServiceHandler.cs | 5 |
2 files changed, 9 insertions, 12 deletions
diff --git a/Emby.Server.Implementations/Services/ResponseHelper.cs b/Emby.Server.Implementations/Services/ResponseHelper.cs index 3c2af60db..22d2b95f7 100644 --- a/Emby.Server.Implementations/Services/ResponseHelper.cs +++ b/Emby.Server.Implementations/Services/ResponseHelper.cs @@ -12,7 +12,7 @@ namespace Emby.Server.Implementations.Services { public static class ResponseHelper { - public static Task WriteToResponse(IResponse httpRes, IRequest httpReq, object result) + public static Task WriteToResponse(IResponse httpRes, IRequest httpReq, object result, CancellationToken cancellationToken) { if (result == null) { @@ -30,21 +30,17 @@ namespace Emby.Server.Implementations.Services { httpResult.RequestContext = httpReq; httpReq.ResponseContentType = httpResult.ContentType ?? httpReq.ResponseContentType; - return WriteToResponseInternal(httpRes, httpResult, httpReq); + return WriteToResponseInternal(httpRes, httpResult, httpReq, cancellationToken); } - return WriteToResponseInternal(httpRes, result, httpReq); + return WriteToResponseInternal(httpRes, result, httpReq, cancellationToken); } /// <summary> /// Writes to response. /// Response headers are customizable by implementing IHasHeaders an returning Dictionary of Http headers. /// </summary> - /// <param name="response">The response.</param> - /// <param name="result">Whether or not it was implicity handled by ServiceStack's built-in handlers.</param> - /// <param name="request">The serialization context.</param> - /// <returns></returns> - private static async Task WriteToResponseInternal(IResponse response, object result, IRequest request) + private static async Task WriteToResponseInternal(IResponse response, object result, IRequest request, CancellationToken cancellationToken) { var defaultContentType = request.ResponseContentType; @@ -105,7 +101,7 @@ namespace Emby.Server.Implementations.Services var asyncStreamWriter = result as IAsyncStreamWriter; if (asyncStreamWriter != null) { - await asyncStreamWriter.WriteToAsync(response.OutputStream, CancellationToken.None).ConfigureAwait(false); + await asyncStreamWriter.WriteToAsync(response.OutputStream, cancellationToken).ConfigureAwait(false); return; } @@ -119,7 +115,7 @@ namespace Emby.Server.Implementations.Services var fileWriter = result as FileWriter; if (fileWriter != null) { - await fileWriter.WriteToAsync(response, CancellationToken.None).ConfigureAwait(false); + await fileWriter.WriteToAsync(response, cancellationToken).ConfigureAwait(false); return; } diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index 8b59b4843..95a9dd682 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Threading; using System.Threading.Tasks; using Emby.Server.Implementations.HttpServer; using MediaBrowser.Model.Logging; @@ -123,7 +124,7 @@ namespace Emby.Server.Implementations.Services // Set from SSHHF.GetHandlerForPathInfo() public string ResponseContentType { get; set; } - public async Task ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, ILogger logger, string operationName) + public async Task ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, ILogger logger, string operationName, CancellationToken cancellationToken) { var restPath = GetRestPath(httpReq.Verb, httpReq.PathInfo); if (restPath == null) @@ -150,7 +151,7 @@ namespace Emby.Server.Implementations.Services responseFilter(httpReq, httpRes, response); } - await ResponseHelper.WriteToResponse(httpRes, httpReq, response).ConfigureAwait(false); + await ResponseHelper.WriteToResponse(httpRes, httpReq, response, cancellationToken).ConfigureAwait(false); } public static object CreateRequest(HttpListenerHost host, IRequest httpReq, RestPath restPath, ILogger logger) |
