Path: blob/trunk/rb/lib/selenium/webdriver/bidi/network/intercepted_response.rb
1865 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 BiDi26class InterceptedResponse < InterceptedItem27attr_accessor :reason, :status28attr_reader :body2930def initialize(network, request)31super32@reason = nil33@status = nil34@body = nil35end3637def continue38network.continue_response(39id: id,40cookies: cookies.as_json,41headers: headers.as_json,42credentials: credentials.as_json,43reason: reason,44status: status45)46end4748def provide_response49network.provide_response(50id: id,51cookies: cookies.as_json,52headers: headers.as_json,53body: body,54reason: reason,55status: status56)57end5859def credentials(username: nil, password: nil)60@credentials ||= Credentials.new(username: username, password: password)61end6263def headers64@headers ||= Headers.new65end6667def cookies(cookies = {})68@cookies ||= Cookies.new(cookies)69end7071def body=(value)72@body = {73type: 'string',74value: value.to_json75}76end77end78end # BiDi79end # WebDriver80end # Selenium818283