diff --git a/src/Microsoft.AspNetCore.Http.Features/IHttpResponseTrailersFeature.cs b/src/Microsoft.AspNetCore.Http.Features/IHttpResponseTrailersFeature.cs new file mode 100644 index 00000000..c0df8e23 --- /dev/null +++ b/src/Microsoft.AspNetCore.Http.Features/IHttpResponseTrailersFeature.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Http.Features +{ + public interface IHttpResponseTrailersFeature + { + /// + /// The response trailers to send. + /// + IHeaderDictionary Trailers { get; set; } + + /// + /// Indicates if the server has started writing the response trailers. + /// If true, the are now immutable, and should no longer be called. + /// + bool HasStarted { get; } + + /// + /// Registers a callback to be invoked just before writing the response trailers. + /// This is the last chance to modify the . + /// + /// The callback to invoke before writing the trailers. + /// The state to pass into the callback. + void OnStarting(Func callback, object state); + } +} diff --git a/src/Microsoft.AspNetCore.Http/Features/HttpResponseTrailersFeature.cs b/src/Microsoft.AspNetCore.Http/Features/HttpResponseTrailersFeature.cs new file mode 100644 index 00000000..de78e35d --- /dev/null +++ b/src/Microsoft.AspNetCore.Http/Features/HttpResponseTrailersFeature.cs @@ -0,0 +1,24 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Http.Features +{ + public class HttpResponseTrailersFeature : IHttpResponseTrailersFeature + { + public HttpResponseTrailersFeature() + { + Trailers = new HeaderDictionary(); + } + + public IHeaderDictionary Trailers { get; set; } + + public virtual bool HasStarted => false; + + public virtual void OnStarting(Func callback, object state) + { + } + } +}