Table of Contents

HttpResponseDecoratorExtensions Class

Definition

Extension methods for the HttpResponse class hidden behind the IDecorator<T> interface.

public static class HttpResponseDecoratorExtensions
Inheritance
HttpResponseDecoratorExtensions

Examples

The following example demonstrates how to add ETag and Last-Modified HTTP response headers using the HttpResponseDecoratorExtensions class accessed through the Decorator class.

// Program.cs
using System;
using System.Text;
using Cuemon;
using Cuemon.AspNetCore.Http;
using Cuemon.Data.Integrity;
using Cuemon.Security;
using Microsoft.AspNetCore.Http;

var context = new DefaultHttpContext();
var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());
builder.CombineWith(Encoding.UTF8.GetBytes("content-data"));

Decorator.Enclose(context.Response).AddOrUpdateEntityTagHeader(context.Request, builder);
var lastModified = new DateTime(2025, 6, 1, 12, 0, 0, DateTimeKind.Utc);
Decorator.Enclose(context.Response).AddOrUpdateLastModifiedHeader(context.Request, lastModified);

Console.WriteLine(context.Response.Headers.ETag.ToString());
Console.WriteLine(context.Response.Headers.LastModified.ToString());

Methods

Name Description
AddOrUpdateEntityTagHeader(IDecorator<HttpResponse>, HttpRequest, ChecksumBuilder, bool)

Attempts to add or update the enclosed HttpResponse of the decorator with the necessary HTTP response headers needed to provide entity tag header information.

AddOrUpdateLastModifiedHeader(IDecorator<HttpResponse>, HttpRequest, DateTime)

Attempts to add or update the enclosed HttpResponse of the decorator with the necessary HTTP response headers needed to provide last-modified information.

See Also