HttpRequestMessageExtensions Class

Namespace
Kampute.HttpClient
Assembly
  • Kampute.HttpClient.dll

Definition

Provides extension methods for HttpRequestMessage that error handlers use to retry a request.
public static class HttpRequestMessageExtensions
Inheritance
  • object
  • HttpRequestMessageExtensions

Methods

CanClone(this HttpRequestMessage)

Determines whether a request can be copied with Clone(this HttpRequestMessage) and sent again.
public static bool CanClone(this HttpRequestMessage request)

Parameters

request HttpRequestMessage
The request to check.

Returns

bool
true if the request has no content or its content can be sent again; otherwise, false.

See Also

Clone(this HttpRequestMessage)

Creates a copy of a request to send again.
public static HttpRequestMessage Clone(this HttpRequestMessage request)

Parameters

request HttpRequestMessage
The request to copy.

Returns

HttpRequestMessage
A new HttpRequestMessage with the method, URI, version, headers, and properties of request.

Exceptions

InvalidOperationException
Thrown if the content of the request cannot be sent again; see CanClone(this HttpRequestMessage).

Remarks

The copy shares the content of the original request rather than copying it, so disposing either request disposes the content of both.

GetCloneGeneration(this HttpRequestMessage)

Returns how many copies separate a request from the original request.
public static int GetCloneGeneration(this HttpRequestMessage request)

Parameters

request HttpRequestMessage
The request to check.

Returns

int
0 for an original request, 1 for a copy of it, 2 for a copy of that copy, and so on. Because each retry of a call clones the request last sent, this is usually the number of retries so far.

See Also

IsCloned(this HttpRequestMessage)

Determines whether a request is a copy made with Clone(this HttpRequestMessage).
public static bool IsCloned(this HttpRequestMessage request)

Parameters

request HttpRequestMessage
The request to check.

Returns

bool
true if the request is a copy; otherwise, false.

See Also