Class HttpResponseExtensions
- Namespace
- Cuemon.Extensions.AspNetCore.Http
- Assembly
- Cuemon.Extensions.AspNetCore.dll
Extension methods for the HttpResponse class.
public static class HttpResponseExtensions
- Inheritance
-
HttpResponseExtensions
Methods
AddOrUpdateEntityTagHeader(HttpResponse, HttpRequest, ChecksumBuilder, bool)
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 HttpResponse to extend.
request
HttpRequestAn instance of the HttpRequest object.
builder
ChecksumBuilderA ChecksumBuilder that represents the integrity of the client.
isWeak
boolA 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 HttpResponse to extend.
request
HttpRequestAn instance of the 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 HttpResponse to extend.
message
HttpResponseMessageThe HttpResponseMessage to convert into an HTTP equivalent HttpResponse.
transformer
Action<HttpResponseMessage, HttpResponse>The delegate that converts a HttpResponseMessage to an HTTP equivalent 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 Task WriteBodyAsync(this HttpResponse response, Func<byte[]> body)
Parameters
response
HttpResponseThe 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.