Sha256: 1213dc4dacb2550ed4e170a9f13a12e6634d40f144a04c3178490b6d8a69ddb8

Contents?: true

Size: 571 Bytes

Versions: 5

Compression:

Stored size: 571 Bytes

Contents

require "anyfetch/open_uri"

module Anyfetch
  class HTTP < OpenURI
    OPTIONS = {
      "User-Agent" => "Mozilla/5.0 (X11; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0",
      :allow_redirections => :safe,
    }

    def initialize(uri, options)
      @uri = uri
      @options = OPTIONS.merge(options)
      setup_basic_auth
    end

    private

    def setup_basic_auth
      if @uri.user || @uri.password
        @options[:http_basic_authentication] = [@uri.user, @uri.password]
        @uri.user = nil
        @uri.password = nil
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
anyfetch-0.1.7 lib/anyfetch/http.rb
anyfetch-0.1.6 lib/anyfetch/http.rb
anyfetch-0.1.5 lib/anyfetch/http.rb
anyfetch-0.1.4 lib/anyfetch/http.rb
anyfetch-0.1.3 lib/anyfetch/http.rb