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.



6
7
8
# File 'lib/playwright_api/response.rb', line 6

def all_headers
  wrap_impl(@impl.all_headers)
end

#bodyObject

Returns the buffer with response body.



11
12
13
# File 'lib/playwright_api/response.rb', line 11

def body
  wrap_impl(@impl.body)
end

#finishedObject

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



16
17
18
# File 'lib/playwright_api/response.rb', line 16

def finished
  wrap_impl(@impl.finished)
end

#frameObject

Returns the ‘Frame` that initiated this response.



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

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)).



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

def from_service_worker
  wrap_impl(@impl.from_service_worker)
end

#from_service_worker?Boolean

Returns:

  • (Boolean)


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

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.



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

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.



52
53
54
# File 'lib/playwright_api/response.rb', line 52

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.



34
35
36
# File 'lib/playwright_api/response.rb', line 34

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.



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

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`.



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

def json
  wrap_impl(@impl.json)
end

#off(event, callback) ⇒ Object

– inherited from EventEmitter –



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

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.



64
65
66
# File 'lib/playwright_api/response.rb', line 64

def ok
  wrap_impl(@impl.ok)
end

#ok?Boolean

Returns:

  • (Boolean)


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

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

#on(event, callback) ⇒ Object

– inherited from EventEmitter –



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

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

#once(event, callback) ⇒ Object

– inherited from EventEmitter –



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

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

#requestObject

Returns the matching ‘Request` object.



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

def request
  wrap_impl(@impl.request)
end

#security_detailsObject

Returns SSL and other security information.



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

def security_details
  wrap_impl(@impl.security_details)
end

#server_addrObject

Returns the IP address and port of the server.



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

def server_addr
  wrap_impl(@impl.server_addr)
end

#statusObject

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



84
85
86
# File 'lib/playwright_api/response.rb', line 84

def status
  wrap_impl(@impl.status)
end

#status_textObject

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



89
90
91
# File 'lib/playwright_api/response.rb', line 89

def status_text
  wrap_impl(@impl.status_text)
end

#textObject

Returns the text representation of response body.



94
95
96
# File 'lib/playwright_api/response.rb', line 94

def text
  wrap_impl(@impl.text)
end

#urlObject

Contains the URL of the response.



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

def url
  wrap_impl(@impl.url)
end