Path: blob/trunk/rb/lib/selenium/webdriver/bidi/network/intercepted_response.rb
4101 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819require_relative 'credentials'20require_relative 'headers'21require_relative 'cookies'2223module Selenium24module WebDriver25class BiDi26#27# @api private28#2930class InterceptedResponse < InterceptedItem31attr_accessor :reason, :status32attr_reader :body3334def initialize(network, request)35super36@reason = nil37@status = nil38@body = nil39@headers = nil40@cookies = nil41end4243def continue44cookies = @cookies&.as_json45headers = @headers&.as_json46network.continue_response(47id: id,48cookies: cookies,49headers: headers,50credentials: credentials.as_json,51reason: reason,52status: status53)54end5556def provide_response57cookies = @cookies&.as_json58headers = @headers&.as_json59network.provide_response(60id: id,61cookies: cookies,62headers: headers,63body: body,64reason: reason,65status: status66)67end6869def credentials(username: nil, password: nil)70@credentials ||= Credentials.new(username: username, password: password)71end7273def headers(headers = {})74@headers ||= Headers.new(headers)75end7677def headers=(*headers)78@headers = Headers.new(headers)79end8081def cookies(cookies = {})82@cookies ||= Cookies.new(cookies)83end8485def cookies=(cookies = {})86@cookies ||= Cookies.new(cookies)87end8889def body=(value)90@body = {91type: 'string',92value: value.to_json93}94end95end96end # BiDi97end # WebDriver98end # Selenium99100101