86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/ferrum/network.rb', line 86
def authorize(user:, password:, type: :server)
unless AUTHORIZE_TYPE.include?(type)
raise ArgumentError, ":type should be in #{AUTHORIZE_TYPE}"
end
@authorized_ids ||= {}
@authorized_ids[type] ||= []
intercept
@page.on(:request) do |request|
request.continue
end
@page.on(:auth) do |request, index, total|
if request.auth_challenge?(type)
response = authorized_response(@authorized_ids[type],
request.request_id,
user, password)
@authorized_ids[type] << request.request_id
request.continue(authChallengeResponse: response)
elsif index + 1 < total
next else
request.abort
end
end
end
|