HarEntryExtensions Class

Provides extension methods for converting HAR entries to HttpRequestMessage and HttpResponseMessage.

public static class HarEntryExtensions

Methods

NameDescription
ToHttpRequestMessage(HarEntry)Creates an HttpRequestMessage from a HAR entry.
ToHttpRequestMessage(HarRequest)Creates an HttpRequestMessage from a HAR request.
ToHttpResponseMessage(HarEntry)Creates an HttpResponseMessage from a HAR entry.
ToHttpResponseMessage(HarResponse)Creates an HttpResponseMessage from a HAR response.

ToHttpRequestMessage overloads

ToHttpRequestMessage(HarEntry)

HarEntryExtensions.cs

Creates an HttpRequestMessage from a HAR entry.

public static HttpRequestMessage ToHttpRequestMessage(this HarEntry entry)
Parameters
entry HarEntry
The HAR entry to convert.
Returns

HttpRequestMessage An HttpRequestMessage representing the HAR request.

Exceptions
InvalidOperationException
The entry does not contain a request.

ToHttpRequestMessage(HarRequest)

HarEntryExtensions.cs

Creates an HttpRequestMessage from a HAR request.

public static HttpRequestMessage ToHttpRequestMessage(this HarRequest request)
Parameters
request HarRequest
The HAR request to convert.
Returns

HttpRequestMessage An HttpRequestMessage representing the HAR request.

Exceptions
InvalidOperationException
The request does not contain a method or a URL.
Remarks

When the archive recorded the body as params instead of text, a application/x-www-form-urlencoded body is rebuilt from the parameters. Multipart bodies cannot be rebuilt this way because the original boundary is not part of the archive; they convert to an empty body.

ToHttpResponseMessage overloads

ToHttpResponseMessage(HarEntry)

HarEntryExtensions.cs

Creates an HttpResponseMessage from a HAR entry.

public static HttpResponseMessage ToHttpResponseMessage(this HarEntry entry)
Parameters
entry HarEntry
The HAR entry to convert.
Returns

HttpResponseMessage An HttpResponseMessage representing the HAR response.

Exceptions
InvalidOperationException
The entry does not contain a response.

ToHttpResponseMessage(HarResponse)

HarEntryExtensions.cs

Creates an HttpResponseMessage from a HAR response.

public static HttpResponseMessage ToHttpResponseMessage(this HarResponse response)
Parameters
response HarResponse
The HAR response to convert.
Returns

HttpResponseMessage An HttpResponseMessage representing the HAR response.