mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
// ==========================================================================
|
|
// FileCallbackResultExecutor.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Internal;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Squidex.Pipeline
|
|
{
|
|
public sealed class FileCallbackResultExecutor : FileResultExecutorBase
|
|
{
|
|
public FileCallbackResultExecutor(ILoggerFactory loggerFactory)
|
|
: base(CreateLogger<VirtualFileResultExecutor>(loggerFactory))
|
|
{
|
|
}
|
|
|
|
public async Task ExecuteAsync(ActionContext context, FileCallbackResult result)
|
|
{
|
|
try
|
|
{
|
|
SetHeadersAndLog(context, result);
|
|
|
|
await result.Callback(context.HttpContext.Response.Body);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.LogCritical(new EventId(99), e, "Failed to send result.");
|
|
|
|
context.HttpContext.Response.Headers.Clear();
|
|
context.HttpContext.Response.StatusCode = 404;
|
|
}
|
|
}
|
|
}
|
|
}
|