Class: Playwright::Response

Inherits:
PlaywrightApi show all
Defined in:
lib/playwright_api/response.rb,
sig/playwright.rbs

Overview

Response class represents responses which are received by page.

Instance Method Summary collapse

Methods inherited from PlaywrightApi

#initialize, unwrap, wrap

Constructor Details

This class inherits a constructor from Playwright::PlaywrightApi

Instance Method Details

#all_headersHash[untyped, untyped]

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

Returns:

  • (Hash[untyped, untyped])


8
9
10
# File 'lib/playwright_api/response.rb', line 8

def all_headers
  wrap_impl(@impl.all_headers)
end

#bodyString

Returns the buffer with response body.

Returns:

  • (String)


14
15
16
# File 'lib/playwright_api/response.rb', line 14

def body
  wrap_impl(@impl.body)
end

#finishednil, String

Waits for this response to finish, returns always null.

Returns:

  • (nil, String)


20
21
22
# File 'lib/playwright_api/response.rb', line 20

def finished
  wrap_impl(@impl.finished)
end

#frameFrame

Returns the Frame that initiated this response.

Returns:



26
27
28
# File 'lib/playwright_api/response.rb', line 26

def frame
  wrap_impl(@impl.frame)
end

#from_service_workerBoolean

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

Returns:

  • (Boolean)


32
33
34
# File 'lib/playwright_api/response.rb', line 32

def from_service_worker
  wrap_impl(@impl.from_service_worker)
end

#from_service_worker?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/playwright_api/response.rb', line 132

def from_service_worker?
  wrap_impl(@impl.from_service_worker?)
end

#header_value(name) ⇒ nil, 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.

Parameters:

  • name (String)

Returns:

  • (nil, String)


54
55
56
# File 'lib/playwright_api/response.rb', line 54

def header_value(name)
  wrap_impl(@impl.header_value(unwrap_impl(name)))
end

#header_values(name) ⇒ Array[untyped]

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

Parameters:

  • name (String)

Returns:

  • (Array[untyped])


60
61
62
# File 'lib/playwright_api/response.rb', line 60

def header_values(name)
  wrap_impl(@impl.header_values(unwrap_impl(name)))
end

#headersHash[untyped, untyped]

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 [method: Response.allHeaders] for complete list of headers that include cookie information.

Returns:

  • (Hash[untyped, untyped])


40
41
42
# File 'lib/playwright_api/response.rb', line 40

def headers
  wrap_impl(@impl.headers)
end

#headers_arrayArray[untyped]

An array with all the request HTTP headers associated with this response. Unlike [method: Response.allHeaders], header names are NOT lower-cased. Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.

Returns:

  • (Array[untyped])


47
48
49
# File 'lib/playwright_api/response.rb', line 47

def headers_array
  wrap_impl(@impl.headers_array)
end

#http_versionString

Returns the http version used by the response.

Returns:

  • (String)


66
67
68
# File 'lib/playwright_api/response.rb', line 66

def http_version
  wrap_impl(@impl.http_version)
end

#jsonObject

Returns the JSON representation of response body.

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

Returns:

  • (Object)


74
75
76
# File 'lib/playwright_api/response.rb', line 74

def json
  wrap_impl(@impl.json)
end

#off(event, callback) ⇒ Object

-- inherited from EventEmitter --



138
139
140
# File 'lib/playwright_api/response.rb', line 138

def off(event, callback)
  event_emitter_proxy.off(event, callback)
end

#okBoolean

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

Returns:

  • (Boolean)


80
81
82
# File 'lib/playwright_api/response.rb', line 80

def ok
  wrap_impl(@impl.ok)
end

#ok?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/playwright_api/response.rb', line 127

def ok?
  wrap_impl(@impl.ok?)
end

#on(event, callback) ⇒ Object

-- inherited from EventEmitter --



150
151
152
# File 'lib/playwright_api/response.rb', line 150

def on(event, callback)
  event_emitter_proxy.on(event, callback)
end

#once(event, callback) ⇒ Object

-- inherited from EventEmitter --



144
145
146
# File 'lib/playwright_api/response.rb', line 144

def once(event, callback)
  event_emitter_proxy.once(event, callback)
end

#requestRequest

Returns the matching Request object.

Returns:



86
87
88
# File 'lib/playwright_api/response.rb', line 86

def request
  wrap_impl(@impl.request)
end

#security_detailsnil, Hash[untyped, untyped]

Returns SSL and other security information.

Returns:

  • (nil, Hash[untyped, untyped])


92
93
94
# File 'lib/playwright_api/response.rb', line 92

def security_details
  wrap_impl(@impl.security_details)
end

#server_addrnil, Hash[untyped, untyped]

Returns the IP address and port of the server.

Returns:

  • (nil, Hash[untyped, untyped])


98
99
100
# File 'lib/playwright_api/response.rb', line 98

def server_addr
  wrap_impl(@impl.server_addr)
end

#statusInteger

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

Returns:

  • (Integer)


104
105
106
# File 'lib/playwright_api/response.rb', line 104

def status
  wrap_impl(@impl.status)
end

#status_textString

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

Returns:

  • (String)


110
111
112
# File 'lib/playwright_api/response.rb', line 110

def status_text
  wrap_impl(@impl.status_text)
end

#textString

Returns the text representation of response body.

Returns:

  • (String)


116
117
118
# File 'lib/playwright_api/response.rb', line 116

def text
  wrap_impl(@impl.text)
end

#urlString

Contains the URL of the response.

Returns:

  • (String)


122
123
124
# File 'lib/playwright_api/response.rb', line 122

def url
  wrap_impl(@impl.url)
end