Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/lib/selenium/webdriver/bidi/network/intercepted_response.rb
1865 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
require_relative 'credentials'
21
require_relative 'headers'
22
require_relative 'cookies'
23
24
module Selenium
25
module WebDriver
26
class BiDi
27
class InterceptedResponse < InterceptedItem
28
attr_accessor :reason, :status
29
attr_reader :body
30
31
def initialize(network, request)
32
super
33
@reason = nil
34
@status = nil
35
@body = nil
36
end
37
38
def continue
39
network.continue_response(
40
id: id,
41
cookies: cookies.as_json,
42
headers: headers.as_json,
43
credentials: credentials.as_json,
44
reason: reason,
45
status: status
46
)
47
end
48
49
def provide_response
50
network.provide_response(
51
id: id,
52
cookies: cookies.as_json,
53
headers: headers.as_json,
54
body: body,
55
reason: reason,
56
status: status
57
)
58
end
59
60
def credentials(username: nil, password: nil)
61
@credentials ||= Credentials.new(username: username, password: password)
62
end
63
64
def headers
65
@headers ||= Headers.new
66
end
67
68
def cookies(cookies = {})
69
@cookies ||= Cookies.new(cookies)
70
end
71
72
def body=(value)
73
@body = {
74
type: 'string',
75
value: value.to_json
76
}
77
end
78
end
79
end # BiDi
80
end # WebDriver
81
end # Selenium
82
83