Class: Playwright::APIResponse

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

Overview

`APIResponse` class represents responses returned by [`method: APIRequestContext.get`] and similar methods.

Instance Method Summary collapse

Methods inherited from PlaywrightApi

#initialize, unwrap, wrap

Constructor Details

This class inherits a constructor from Playwright::PlaywrightApi

Instance Method Details

#bodyObject

Returns the buffer with response body.



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

def body
  wrap_impl(@impl.body)
end

#disposeObject

Disposes the body of this response. If not called then the body will stay in memory until the context closes.



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

def dispose
  wrap_impl(@impl.dispose)
end

#headersObject

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



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

def headers
  wrap_impl(@impl.headers)
end

#headers_arrayObject

An array with all the request HTTP headers associated with this response. Header names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.



22
23
24
# File 'lib/playwright_api/api_response.rb', line 22

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



29
30
31
# File 'lib/playwright_api/api_response.rb', line 29

def json
  wrap_impl(@impl.json)
end

#okObject

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



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

def ok
  wrap_impl(@impl.ok)
end

#ok?Boolean

Returns:

  • (Boolean)


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

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

#statusObject

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



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

def status
  wrap_impl(@impl.status)
end

#status_textObject

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



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

def status_text
  wrap_impl(@impl.status_text)
end

#textObject

Returns the text representation of response body.



49
50
51
# File 'lib/playwright_api/api_response.rb', line 49

def text
  wrap_impl(@impl.text)
end

#to_sObject



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

def to_s
  wrap_impl(@impl.to_s)
end

#urlObject

Contains the URL of the response.



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

def url
  wrap_impl(@impl.url)
end