Class: Ferrum::Network::AuthRequest
- Inherits:
-
Object
- Object
- Ferrum::Network::AuthRequest
- Includes:
- RequestParams
- Defined in:
- lib/ferrum/network/auth_request.rb,
sig/ferrum/network/auth_request.rbs
Overview
Represents an HTTP authentication challenge (basic or digest auth
prompt) raised by the browser via Fetch.authRequired, which can be
answered with credentials or canceled.
Instance Attribute Summary collapse
- #frame_id ⇒ ::String
-
#id ⇒ String
The id of the paused request, the
requestIdthatFetchcommands take. - #resource_type ⇒ "Document", ...
Instance Method Summary collapse
-
#abort ⇒ Object
Cancels the authentication challenge, so the request completes with the unauthorized response.
-
#auth_challenge?(source) ⇒ Boolean
Whether the authentication challenge's source matches the given type.
-
#continue(**options) ⇒ Object
Responds to the authentication challenge, e.g.
-
#handled? ⇒ Boolean
Whether the challenge was answered or canceled.
-
#initialize(page, params) ⇒ AuthRequest
constructor
A new instance of AuthRequest.
-
#inspect ⇒ String
Inspects the auth request.
-
#navigation_request? ⇒ Boolean
Whether this request is for the navigation of a frame, as opposed to a subresource (script, image, XHR, etc).
Methods included from RequestParams
#body, #headers, #initial_priority, #match?, #method, #referrer_policy, #url, #url_fragment
Constructor Details
#initialize(page, params) ⇒ AuthRequest
Returns a new instance of AuthRequest.
28 29 30 31 32 33 34 35 36 |
# File 'lib/ferrum/network/auth_request.rb', line 28 def initialize(page, params) @page = page @params = params @id = params["requestId"] @frame_id = params["frameId"] @resource_type = params["resourceType"] @request = params["request"] @handled = false end |
Instance Attribute Details
#frame_id ⇒ ::String
The writer is a private API, Ferrum sets it.
23 24 25 |
# File 'lib/ferrum/network/auth_request.rb', line 23 def frame_id @frame_id end |
#id ⇒ String
The writer is a private API, Ferrum sets it.
The id of the paused request, the requestId that Fetch commands take.
20 21 22 |
# File 'lib/ferrum/network/auth_request.rb', line 20 def id @id end |
#resource_type ⇒ "Document", ...
The writer is a private API, Ferrum sets it.
23 24 25 |
# File 'lib/ferrum/network/auth_request.rb', line 23 def resource_type @resource_type end |
Instance Method Details
#abort ⇒ Object
Cancels the authentication challenge, so the request completes with the unauthorized response.
93 94 95 |
# File 'lib/ferrum/network/auth_request.rb', line 93 def abort continue(authChallengeResponse: { response: "CancelAuth" }) end |
#auth_challenge?(source) ⇒ Boolean
Whether the authentication challenge's source matches the given type.
66 67 68 |
# File 'lib/ferrum/network/auth_request.rb', line 66 def auth_challenge?(source) @params.dig("authChallenge", "source")&.downcase&.to_s == source.to_s end |
#continue(**options) ⇒ Object
Responds to the authentication challenge, e.g. with credentials or by canceling it.
83 84 85 86 87 |
# File 'lib/ferrum/network/auth_request.rb', line 83 def continue(**) = .merge(requestId: id) @handled = true @page.command("Fetch.continueWithAuth", **) end |
#handled? ⇒ Boolean
Whether the challenge was answered or canceled.
43 44 45 |
# File 'lib/ferrum/network/auth_request.rb', line 43 def handled? @handled end |
#inspect ⇒ String
Inspects the auth request.
102 103 104 105 106 107 108 |
# File 'lib/ferrum/network/auth_request.rb', line 102 def inspect "#<#{self.class} " \ "@id=#{@id.inspect} " \ "@frame_id=#{@frame_id.inspect} " \ "@resource_type=#{@resource_type.inspect} " \ "@request=#{@request.inspect}>" end |
#navigation_request? ⇒ Boolean
Whether this request is for the navigation of a frame, as opposed to a subresource (script, image, XHR, etc).
53 54 55 |
# File 'lib/ferrum/network/auth_request.rb', line 53 def resource_type == "Document" end |