class Ferrum::Network::Response
Attributes
body_size[R]
Public Class Methods
new(page, params)
click to toggle source
# File lib/ferrum/network/response.rb, line 8 def initialize(page, params) @page = page @params = params @response = params["response"] || params["redirectResponse"] end
Public Instance Methods
==(other)
click to toggle source
# File lib/ferrum/network/response.rb, line 68 def ==(other) id == other.id end
body()
click to toggle source
# File lib/ferrum/network/response.rb, line 55 def body @body ||= begin body, encoded = @page .command("Network.getResponseBody", requestId: id) .values_at("body", "base64Encoded") encoded ? Base64.decode64(body) : body end end
body_size=(size)
click to toggle source
See crbug.com/883475 Sometimes we never get the Network.responseReceived event. See crbug.com/764946 `Network.loadingFinished` encodedDataLength contains both body and headers sizes received by wire.
# File lib/ferrum/network/response.rb, line 51 def body_size=(size) @body_size = size - headers_size end
content_type()
click to toggle source
# File lib/ferrum/network/response.rb, line 42 def content_type @content_type ||= headers.find { |k, _| k.downcase == "content-type" }&.last&.sub(/;.*\z/, "") end
headers()
click to toggle source
# File lib/ferrum/network/response.rb, line 30 def headers @response["headers"] end
headers_size()
click to toggle source
# File lib/ferrum/network/response.rb, line 34 def headers_size @response["encodedDataLength"] end
id()
click to toggle source
# File lib/ferrum/network/response.rb, line 14 def id @params["requestId"] end
inspect()
click to toggle source
# File lib/ferrum/network/response.rb, line 72 def inspect %(#<#{self.class} @params=#{@params.inspect} @response=#{@response.inspect}>) end
main?()
click to toggle source
# File lib/ferrum/network/response.rb, line 64 def main? @page.network.response == self end
status()
click to toggle source
# File lib/ferrum/network/response.rb, line 22 def status @response["status"] end
status_text()
click to toggle source
# File lib/ferrum/network/response.rb, line 26 def status_text @response["statusText"] end
type()
click to toggle source
# File lib/ferrum/network/response.rb, line 38 def type @params["type"] end
url()
click to toggle source
# File lib/ferrum/network/response.rb, line 18 def url @response["url"] end