Sha256: f332b80f3412ac0144d1cbe1a8bdf2dd731fb79dae9d6fc260a95faa94541359

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

module Selenium
  module WebDriver
    class DevTools
      class Request

        attr_reader :url, :method, :headers

        def initialize(devtools:, id:, url:, method:, headers:)
          @devtools = devtools
          @id = id
          @url = url
          @method = method
          @headers = headers
        end

        def continue
          @devtools.fetch.continue_request(request_id: @id)
        end

        def respond(code: 200, headers: {}, body: '')
          @devtools.fetch.fulfill_request(
            request_id: @id,
            body: Base64.strict_encode64(body),
            response_code: code,
            response_headers: headers.map do |k, v|
              {name: k, value: v}
            end
          )
        end

        def inspect
          %(#<#{self.class.name} @method="#{method}" @url="#{url}")
        end

      end # Request
    end # DevTools
  end # WebDriver
end # Selenium

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
selenium-webdriver-4.0.0.rc1 lib/selenium/webdriver/devtools/request.rb
selenium-webdriver-4.0.0.beta4 lib/selenium/webdriver/devtools/request.rb
selenium-webdriver-4.0.0.beta3 lib/selenium/webdriver/devtools/request.rb
selenium-webdriver-4.0.0.beta2 lib/selenium/webdriver/devtools/request.rb