Sha256: f3f42f4807f0b389112825344d9b35c7c42b88284c26b59a04eb72646ab7fd9b

Contents?: true

Size: 1018 Bytes

Versions: 62

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

module Faraday
  # ProxyOptions contains the configurable properties for the proxy
  # configuration used when making an HTTP request.
  class ProxyOptions < Options.new(:uri, :user, :password)
    extend Forwardable
    def_delegators :uri, :scheme, :scheme=, :host, :host=, :port, :port=,
                   :path, :path=

    def self.from(value)
      case value
      when String
        # URIs without a scheme should default to http (like 'example:123').
        # This fixes #1282 and prevents a silent failure in some adapters.
        value = "http://#{value}" unless value.include?('://')
        value = { uri: Utils.URI(value) }
      when URI
        value = { uri: value }
      when Hash, Options
        if (uri = value.delete(:uri))
          value[:uri] = Utils.URI(uri)
        end
      end

      super(value)
    end

    memoized(:user) { uri&.user && Utils.unescape(uri.user) }
    memoized(:password) { uri&.password && Utils.unescape(uri.password) }
  end
end

Version data entries

62 entries across 58 versions & 9 rubygems

Version Path
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.8.0/lib/faraday/options/proxy_options.rb
faraday-2.0.0.alpha.pre.3 lib/faraday/options/proxy_options.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/options/proxy_options.rb
faraday-2.0.0.alpha.pre.2 lib/faraday/options/proxy_options.rb
faraday-2.0.0.alpha.pre.1 lib/faraday/options/proxy_options.rb
faraday-1.8.0 lib/faraday/options/proxy_options.rb
faraday-1.7.2 lib/faraday/options/proxy_options.rb
faraday-1.7.1 lib/faraday/options/proxy_options.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/faraday-1.7.0/lib/faraday/options/proxy_options.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/faraday-1.4.2/lib/faraday/options/proxy_options.rb
mx-platform-ruby-0.4.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.7.0/lib/faraday/options/proxy_options.rb
mx-platform-ruby-0.3.2 vendor/bundle/ruby/2.6.0/gems/faraday-1.7.0/lib/faraday/options/proxy_options.rb
mx-platform-ruby-0.3.1 vendor/bundle/ruby/2.6.0/gems/faraday-1.7.0/lib/faraday/options/proxy_options.rb
faraday-1.7.0 lib/faraday/options/proxy_options.rb
faraday-1.6.0 lib/faraday/options/proxy_options.rb
faraday-1.5.1 lib/faraday/options/proxy_options.rb
faraday-1.5.0 lib/faraday/options/proxy_options.rb
faraday-1.4.3 lib/faraday/options/proxy_options.rb
passbase-1.3.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.4.2/lib/faraday/options/proxy_options.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/faraday-1.4.2/lib/faraday/options/proxy_options.rb