Table of Contents

Interface IResponse

Namespace
Microsoft.Playwright
Assembly
Microsoft.Playwright.dll

IResponse class represents responses which are received by page.

public interface IResponse

Properties

Frame

Returns the IFrame that initiated this response.

IFrame Frame { get; }

Property Value

IFrame

FromServiceWorker

Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via FetchEvent.respondWith).

bool FromServiceWorker { get; }

Property Value

bool

Headers

An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return security-related headers, including cookie-related ones. You can use AllHeadersAsync() for complete list of headers that include cookie information.

Dictionary<string, string> Headers { get; }

Property Value

Dictionary<string, string>

Ok

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

bool Ok { get; }

Property Value

bool

Request

Returns the matching IRequest object.

IRequest Request { get; }

Property Value

IRequest

Status

Contains the status code of the response (e.g., 200 for a success).

int Status { get; }

Property Value

int

StatusText

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

string StatusText { get; }

Property Value

string

Url

Contains the URL of the response.

string Url { get; }

Property Value

string

Methods

AllHeadersAsync()

An object with all the response HTTP headers associated with this response.

Task<Dictionary<string, string>> AllHeadersAsync()

Returns

Task<Dictionary<string, string>>

BodyAsync()

Returns the buffer with response body.

Task<byte[]> BodyAsync()

Returns

Task<byte[]>

FinishedAsync()

Waits for this response to finish, returns always null.

Task<string?> FinishedAsync()

Returns

Task<string>

HeaderValueAsync(string)

Returns the value of the header matching the name. The name is case insensitive. If multiple headers have the same name (except set-cookie), they are returned as a list separated by , . For set-cookie, the \n separator is used. If no headers are found, null is returned.

Task<string?> HeaderValueAsync(string name)

Parameters

name string

Name of the header.

Returns

Task<string>

HeaderValuesAsync(string)

Returns all values of the headers matching the name, for example set-cookie. The name is case insensitive.

Task<IReadOnlyList<string>> HeaderValuesAsync(string name)

Parameters

name string

Name of the header.

Returns

Task<IReadOnlyList<string>>

HeadersArrayAsync()

An array with all the request HTTP headers associated with this response. Unlike AllHeadersAsync(), header names are NOT lower-cased. Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.

Task<IReadOnlyList<Header>> HeadersArrayAsync()

Returns

Task<IReadOnlyList<Header>>

JsonAsync()

Returns the JSON representation of response body.

This method will throw if the response body is not parsable via JSON.parse.

Task<JsonElement?> JsonAsync()

Returns

Task<JsonElement?>

JsonAsync<T>()

Task<T> JsonAsync<T>()

Returns

Task<T>

Type Parameters

T

SecurityDetailsAsync()

Returns SSL and other security information.

Task<ResponseSecurityDetailsResult?> SecurityDetailsAsync()

Returns

Task<ResponseSecurityDetailsResult>

ServerAddrAsync()

Returns the IP address and port of the server.

Task<ResponseServerAddrResult?> ServerAddrAsync()

Returns

Task<ResponseServerAddrResult>

TextAsync()

Returns the text representation of response body.

Task<string> TextAsync()

Returns

Task<string>