# `Playwright.Response`
[🔗](https://github.com/ftes/playwright_ex/blob/v1.65.0-rc.3/lib/playwright/api/response.ex#L7)

[`Response`](`Playwright.Response`) class represents responses which are received by page.

*Since Playwright 1.8.*

The examples alias the modules they use (`alias Playwright.{Locator, Page}`).

# `t`

```elixir
@type t() :: %Playwright.Response{
  conn: term(),
  guid: term(),
  initializer: term(),
  table: term(),
  type: term()
}
```

A `Response` handle. Compare handles with `==`, their fields are internal.

# `all_headers`

```elixir
@spec all_headers(t()) ::
  {:ok, %{optional(String.t()) =&gt; String.t()}} | {:error, Playwright.error()}
```

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

*Since Playwright 1.15.*

# `all_headers!`

```elixir
@spec all_headers!(t()) :: %{optional(String.t()) =&gt; String.t()}
```

Like `all_headers/1`, but returns the value and raises on error.

# `body`

```elixir
@spec body(t()) :: {:ok, binary()} | {:error, Playwright.error()}
```

Returns the buffer with response body.

*Since Playwright 1.8.*

# `body!`

```elixir
@spec body!(t()) :: binary()
```

Like `body/1`, but returns the value and raises on error.

# `finished`

```elixir
@spec finished(t()) :: {:ok, nil | Exception.t()} | {:error, Playwright.error()}
```

Waits for this response to finish, returns always `nil`.

*Since Playwright 1.8.*

# `finished!`

```elixir
@spec finished!(t()) :: nil | Exception.t()
```

Like `finished/1`, but returns the value and raises on error.

# `frame`

```elixir
@spec frame(t()) :: Playwright.Frame.t()
```

Returns the [`Frame`](`Playwright.Frame`) that initiated this response.

*Since Playwright 1.8.*

# `from_service_worker`

```elixir
@spec from_service_worker(t()) :: boolean()
```

Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).

*Since Playwright 1.23.*

# `header_value`

```elixir
@spec header_value(t(), String.t()) ::
  {:ok, nil | String.t()} | {:error, Playwright.error()}
```

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, `nil` is returned.

*Since Playwright 1.15.*

## Arguments

* `name` - Name of the header.

# `header_value!`

```elixir
@spec header_value!(t(), String.t()) :: nil | String.t()
```

Like `header_value/2`, but returns the value and raises on error.

# `header_values`

```elixir
@spec header_values(t(), String.t()) ::
  {:ok, [String.t()]} | {:error, Playwright.error()}
```

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

*Since Playwright 1.15.*

## Arguments

* `name` - Name of the header.

# `header_values!`

```elixir
@spec header_values!(t(), String.t()) :: [String.t()]
```

Like `header_values/2`, but returns the value and raises on error.

# `headers`

```elixir
@spec headers(t()) :: %{optional(String.t()) =&gt; String.t()}
```

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 `Playwright.Response.all_headers/1` for complete list of headers that include `cookie` information.

*Since Playwright 1.8.*

# `headers_array`

```elixir
@spec headers_array(t()) ::
  {:ok, [%{name: String.t(), value: String.t()}]} | {:error, Playwright.error()}
```

An array with all the response HTTP headers associated with this response. Unlike `Playwright.Response.all_headers/1`, header names are NOT lower-cased.
Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
Some browser network stacks combine multiple field values before reporting them, so separate entries are not always available.

*Since Playwright 1.15.*

# `headers_array!`

```elixir
@spec headers_array!(t()) :: [%{name: String.t(), value: String.t()}]
```

Like `headers_array/1`, but returns the value and raises on error.

# `http_version`

```elixir
@spec http_version(t()) :: {:ok, String.t()} | {:error, Playwright.error()}
```

Returns the http version used by the response.

*Since Playwright 1.59.*

# `http_version!`

```elixir
@spec http_version!(t()) :: String.t()
```

Like `http_version/1`, but returns the value and raises on error.

# `json`

```elixir
@spec json(t()) :: {:ok, term()} | {:error, Playwright.error()}
```

Returns the JSON representation of response body.

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

*Since Playwright 1.8.*

# `json!`

```elixir
@spec json!(t()) :: term()
```

Like `json/1`, but returns the value and raises on error.

# `ok`

```elixir
@spec ok(t()) :: boolean()
```

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

*Since Playwright 1.8.*

# `request`

```elixir
@spec request(t()) :: Playwright.Request.t()
```

Returns the matching [`Request`](`Playwright.Request`) object.

*Since Playwright 1.8.*

# `security_details`

```elixir
@spec security_details(t()) ::
  {:ok,
   nil
   | %{
       optional(:issuer) =&gt; String.t(),
       optional(:protocol) =&gt; String.t(),
       optional(:subjectName) =&gt; String.t(),
       optional(:validFrom) =&gt; number(),
       optional(:validTo) =&gt; number()
     }}
  | {:error, Playwright.error()}
```

Returns SSL and other security information.

*Since Playwright 1.13.*

# `security_details!`

```elixir
@spec security_details!(t()) ::
  nil
  | %{
      optional(:issuer) =&gt; String.t(),
      optional(:protocol) =&gt; String.t(),
      optional(:subjectName) =&gt; String.t(),
      optional(:validFrom) =&gt; number(),
      optional(:validTo) =&gt; number()
    }
```

Like `security_details/1`, but returns the value and raises on error.

# `server_addr`

```elixir
@spec server_addr(t()) ::
  {:ok, nil | %{ipAddress: String.t(), port: integer()}}
  | {:error, Playwright.error()}
```

Returns the IP address and port of the server.

*Since Playwright 1.13.*

# `server_addr!`

```elixir
@spec server_addr!(t()) :: nil | %{ipAddress: String.t(), port: integer()}
```

Like `server_addr/1`, but returns the value and raises on error.

# `status`

```elixir
@spec status(t()) :: integer()
```

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

*Since Playwright 1.8.*

# `status_text`

```elixir
@spec status_text(t()) :: String.t()
```

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

*Since Playwright 1.8.*

# `text`

```elixir
@spec text(t()) :: {:ok, String.t()} | {:error, Playwright.error()}
```

Returns the text representation of response body.

*Since Playwright 1.8.*

# `text!`

```elixir
@spec text!(t()) :: String.t()
```

Like `text/1`, but returns the value and raises on error.

# `url`

```elixir
@spec url(t()) :: String.t()
```

Contains the URL of the response.

*Since Playwright 1.8.*

---

*Consult [api-reference.md](api-reference.md) for complete listing*
