Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/lib/selenium/webdriver/devtools/request.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
module Selenium
21
module WebDriver
22
class DevTools
23
class Request
24
attr_accessor :url, :method, :headers, :post_data
25
attr_reader :id
26
27
#
28
# Creates request from DevTools message.
29
# @api private
30
#
31
32
def self.from(id, params)
33
new(
34
id: id,
35
url: params.dig('request', 'url'),
36
method: params.dig('request', 'method'),
37
headers: params.dig('request', 'headers').dup,
38
post_data: params.dig('request', 'postData')
39
)
40
end
41
42
def initialize(id:, url:, method:, headers:, post_data:)
43
@id = id
44
@url = url
45
@method = method
46
@headers = headers
47
@post_data = post_data
48
end
49
50
def ==(other)
51
self.class == other.class &&
52
id == other.id &&
53
url == other.url &&
54
method == other.method &&
55
headers == other.headers &&
56
post_data == other.post_data
57
end
58
59
def inspect
60
%(#<#{self.class.name} @id="#{id}" @method="#{method}" @url="#{url}")
61
end
62
end # Request
63
end # DevTools
64
end # WebDriver
65
end # Selenium
66
67