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

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



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

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.



44
45
46
# File 'lib/playwright_api/response.rb', line 44

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

#headersObject

DEPRECATED Incomplete list of headers as seen by the rendering engine. Use [‘method: Response.allHeaders`] instead.



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

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.



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

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



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

def json
  wrap_impl(@impl.json)
end

#off(event, callback) ⇒ Object

– inherited from EventEmitter –



102
103
104
# File 'lib/playwright_api/response.rb', line 102

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.



56
57
58
# File 'lib/playwright_api/response.rb', line 56

def ok
  wrap_impl(@impl.ok)
end

#ok?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/playwright_api/response.rb', line 96

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

#on(event, callback) ⇒ Object

– inherited from EventEmitter –



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

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

#once(event, callback) ⇒ Object

– inherited from EventEmitter –



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

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

#requestObject

Returns the matching ‘Request` object.



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

def request
  wrap_impl(@impl.request)
end

#security_detailsObject

Returns SSL and other security information.



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

def security_details
  wrap_impl(@impl.security_details)
end

#server_addrObject

Returns the IP address and port of the server.



71
72
73
# File 'lib/playwright_api/response.rb', line 71

def server_addr
  wrap_impl(@impl.server_addr)
end

#statusObject

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



76
77
78
# File 'lib/playwright_api/response.rb', line 76

def status
  wrap_impl(@impl.status)
end

#status_textObject

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



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

def status_text
  wrap_impl(@impl.status_text)
end

#textObject

Returns the text representation of response body.



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

def text
  wrap_impl(@impl.text)
end

#urlObject

Contains the URL of the response.



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

def url
  wrap_impl(@impl.url)
end