Sha256: 4149957c3d81d3377b8e9441f4e0826106780ed1d5a193fe39cfb18421252eb2

Contents?: true

Size: 675 Bytes

Versions: 8

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Gateways
    class Http
      attr_reader :driver

      def initialize(driver: Http.default_driver)
        @driver = driver
      end

      def get(uri, default: nil)
        driver.with_retry do |client|
          client.get(uri)
        end
      rescue *Net::Hippie::CONNECTION_ERRORS
        default
      end

      def ok?(response)
        response.is_a?(Net::HTTPSuccess)
      end

      def self.default_driver
        @default_driver ||= Net::Hippie::Client.new.tap do |client|
          client.logger = ::Logger.new('http.log')
          client.follow_redirects = 3
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spandx-0.3.0 lib/spandx/gateways/http.rb
spandx-0.2.0 lib/spandx/gateways/http.rb
spandx-0.1.7 lib/spandx/gateways/http.rb
spandx-0.1.6 lib/spandx/gateways/http.rb
spandx-0.1.5 lib/spandx/gateways/http.rb
spandx-0.1.4 lib/spandx/gateways/http.rb
spandx-0.1.3 lib/spandx/gateways/http.rb
spandx-0.1.2 lib/spandx/gateways/http.rb