Skip to content

Response<TRequest>

Namespace: PuppeteerSharp

public abstract class Response<TRequest> : IResponse where TRequest : IRequest

Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.

Type parameters

Name Description
TRequest

Inheritance: object

Implements: IResponse

Derived: BidiHttpResponse, CdpHttpResponse

View source

public IFrame Frame { get; }

A Frame that initiated this request. Or null if navigating to error pages.

Value: IFrame

View source

public abstract bool FromCache { get; }

True if the response was served from either the browser’s disk cache or memory cache.

Value: bool

View source

public bool FromServiceWorker { get; protected init; }

Gets a value indicating whether the IResponse was served by a service worker.

Value: bool — true if the IResponse was served by a service worker; otherwise, false.

View source

public Dictionary<string, string> Headers { get; protected init; }

An object with HTTP headers associated with the response. All header names are lower-case. Duplicate header values are combined into a single comma-separated list except for Set-Cookie that is separated by \n.

Value: Dictionary<string, string> — The headers.

View source

public bool Ok { get; }

Contains a boolean stating whether the response was successful (status in the range 200-299) or not.

Value: bool — true if ok; otherwise, false.

View source

public RemoteAddress RemoteAddress { get; protected init; }

Remove server address.

Value: RemoteAddress

View source

protected TRequest Request { get; init; }

Value: TRequest

View source

public SecurityDetails SecurityDetails { get; protected init; }

Gets or sets the security details.

Value: SecurityDetails — The security details.

View source

public HttpStatusCode Status { get; protected init; }

Contains the status code of the response.

Value: HttpStatusCode — The status.

View source

public string StatusText { get; protected init; }

Contains the status text of the response (e.g. usually an “OK” for a success).

Value: string — The status text.

View source

public ResourceTiming Timing { get; protected init; }

Resource timing information for this response.

Value: ResourceTiming

View source

public string Url { get; protected init; }

Contains the URL of the response.

Value: string

View source

public Task<HttpResponseMessage> AsFetchResponseAsync()

Converts the response to an HttpResponseMessage instance.

Returns: Task<HttpResponseMessage> — A Task which resolves to an HttpResponseMessage representation of the response.

Headers are copied to the new response, with multi-line set-cookie headers split into individual header entries. For responses with null body statuses (101, 204, 205, 304), the body is omitted.

View source

public abstract ValueTask<byte[]> BufferAsync()

Returns a Task which resolves to a buffer with response body.

Returns: ValueTask<byte[]> — A Task which resolves to a buffer with response body.

View source

public Task<JsonDocument> JsonAsync(JsonDocumentOptions options = default)

Returns a Task which resolves to a JsonDocument representation of response body.

Parameters

Name Type Description
options JsonDocumentOptions Parsing options.

Returns: Task<JsonDocument> — A Task which resolves to a JsonDocument representation of response body.

View source

public Task<T> JsonAsync<T>(JsonSerializerOptions options = null)

Returns a Task which resolves to a <code class=“typeparamref”>T</code> representation of response body.

Type parameters

Name Description
T The type of the response.

Parameters

Name Type Description
options JsonSerializerOptions Parsing options.

Returns: Task<T> — A Task which resolves to a <code class=“typeparamref”>T</code> representation of response body.

View source

public Task<string> TextAsync()

Returns a Task which resolves to a text representation of response body.

Returns: Task<string> — A Task which resolves to a text representation of response body.

View source

Made with love by Dario Kondratiuk