Class: Playwright::Response

Inherits:
PlaywrightApi show all
Defined in:
lib/playwright_api/response.rb

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_headersObject

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



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

def all_headers
  wrap_impl(@impl.all_headers)
end

#bodyObject

Returns the buffer with response body.



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

def body
  wrap_impl(@impl.body)
end

#finishedObject

Waits for this response to finish, returns always ‘null`.



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

def finished
  wrap_impl(@impl.finished)
end

#frameObject

Returns the ‘Frame` that initiated this response.



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

def frame
  wrap_impl(@impl.frame)
end

#from_service_workerObject

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



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)


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

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

#header_value(name) ⇒ Object

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.



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) ⇒ Object

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



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

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

#headersObject

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.



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

def headers
  wrap_impl(@impl.headers)
end

#headers_arrayObject

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.



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

def headers_array
  wrap_impl(@impl.headers_array)
end

#jsonObject

Returns the JSON representation of response body.

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



68
69
70
# File 'lib/playwright_api/response.rb', line 68

def json
  wrap_impl(@impl.json)
end

#off(event, callback) ⇒ Object

– inherited from EventEmitter –



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

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

#okObject

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



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

def ok
  wrap_impl(@impl.ok)
end

#ok?Boolean

Returns:

  • (Boolean)


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

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

#on(event, callback) ⇒ Object

– inherited from EventEmitter –



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

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

#once(event, callback) ⇒ Object

– inherited from EventEmitter –



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

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

#requestObject

Returns the matching ‘Request` object.



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

def request
  wrap_impl(@impl.request)
end

#security_detailsObject

Returns SSL and other security information.



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

def security_details
  wrap_impl(@impl.security_details)
end

#server_addrObject

Returns the IP address and port of the server.



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

def server_addr
  wrap_impl(@impl.server_addr)
end

#statusObject

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



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

def status
  wrap_impl(@impl.status)
end

#status_textObject

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



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

def status_text
  wrap_impl(@impl.status_text)
end

#textObject

Returns the text representation of response body.



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

def text
  wrap_impl(@impl.text)
end

#urlObject

Contains the URL of the response.



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

def url
  wrap_impl(@impl.url)
end