Class HttpResponseExtensions
- Namespace
- Cuemon.Extensions.AspNetCore.Http
- Assembly
- Cuemon.Extensions.AspNetCore.dll
Extension methods for the Microsoft.AspNetCore.Http.HttpResponse class.
public static class HttpResponseExtensions
- Inheritance
-
HttpResponseExtensions
Methods
AddOrUpdateEntityTagHeader(HttpResponse, HttpRequest, ChecksumBuilder, Boolean)
Attempts to add or update the necessary HTTP response headers needed to provide entity tag header information.
public static void AddOrUpdateEntityTagHeader(this HttpResponse response, HttpRequest request, ChecksumBuilder builder, bool isWeak = false)
Parameters
response
HttpResponseThe Microsoft.AspNetCore.Http.HttpResponse to extend.
request
HttpRequestAn instance of the Microsoft.AspNetCore.Http.HttpRequest object.
builder
ChecksumBuilderA ChecksumBuilder that represents the integrity of the client.
isWeak
BooleanA value that indicates if this entity-tag header is a weak validator.
Exceptions
- ArgumentNullException
response
cannot be null -or-request
cannot be null -or-builder
cannot be null.
AddOrUpdateLastModifiedHeader(HttpResponse, HttpRequest, DateTime)
Attempts to add or update the necessary HTTP response headers needed to provide last-modified information.
public static void AddOrUpdateLastModifiedHeader(this HttpResponse response, HttpRequest request, DateTime lastModified)
Parameters
response
HttpResponseThe Microsoft.AspNetCore.Http.HttpResponse to extend.
request
HttpRequestAn instance of the Microsoft.AspNetCore.Http.HttpRequest object.
lastModified
DateTimeA value that represents when the resource was either created or last modified.
Exceptions
- ArgumentNullException
response
cannot be null -or-request
cannot be null.
OnStartingInvokeTransformer(HttpResponse, HttpResponseMessage, Action<HttpResponseMessage, HttpResponse>)
Transfers the specified message
to the HTTP response
pipeline using the transformer
delegate.
public static void OnStartingInvokeTransformer(this HttpResponse response, HttpResponseMessage message, Action<HttpResponseMessage, HttpResponse> transformer)
Parameters
response
HttpResponseThe Microsoft.AspNetCore.Http.HttpResponse to extend.
message
HttpResponseMessageThe HttpResponseMessage to convert into an HTTP equivalent Microsoft.AspNetCore.Http.HttpResponse.
transformer
Action<HttpResponseMessage, HttpResponse>The delegate that converts a HttpResponseMessage to an HTTP equivalent Microsoft.AspNetCore.Http.HttpResponse.
WriteBodyAsync(HttpResponse, Func<Byte[]>)
Asynchronously writes a sequence of bytes to the response body stream and advances the current position within this stream by the number of bytes written.
public static async Task WriteBodyAsync(this HttpResponse response, Func<byte[]> body)
Parameters
response
HttpResponseThe Microsoft.AspNetCore.Http.HttpResponse to extend.
body
Func<Byte[]>The function delegate that resolves the bytes to write.
Returns
- Task
A task that represents the asynchronous write operation.