update tasks
This commit is contained in:
parent
b527e56ec3
commit
d21e8d3c33
|
@ -12,39 +12,28 @@ namespace Emby.Server.Implementations.Services
|
||||||
{
|
{
|
||||||
public static class ResponseHelper
|
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 (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);
|
response.SetContentLength(0);
|
||||||
return Task.FromResult(true);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var httpResult = result as IHttpResult;
|
var httpResult = result as IHttpResult;
|
||||||
if (httpResult != null)
|
if (httpResult != null)
|
||||||
{
|
{
|
||||||
httpResult.RequestContext = httpReq;
|
httpResult.RequestContext = request;
|
||||||
httpReq.ResponseContentType = httpResult.ContentType ?? httpReq.ResponseContentType;
|
request.ResponseContentType = httpResult.ContentType ?? request.ResponseContentType;
|
||||||
return WriteToResponseInternal(httpRes, httpResult, httpReq, cancellationToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 defaultContentType = request.ResponseContentType;
|
||||||
|
|
||||||
var httpResult = result as IHttpResult;
|
|
||||||
if (httpResult != null)
|
if (httpResult != null)
|
||||||
{
|
{
|
||||||
if (httpResult.RequestContext == null)
|
if (httpResult.RequestContext == null)
|
||||||
|
|
|
@ -8,9 +8,4 @@ namespace MediaBrowser.Model.Services
|
||||||
{
|
{
|
||||||
Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken);
|
Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IFileWriter
|
|
||||||
{
|
|
||||||
Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user