Sha256: ef574b9cff44d40bb297d6fa8f6b98e9ae4418960ac62c4b85e59f5742197980

Contents?: true

Size: 1.08 KB

Versions: 36

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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

    def self.from(value)
      case value
      when ''
        value = nil
      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

36 entries across 36 versions & 3 rubygems

Version Path
es_cli-0.1.0 vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/proxy_options.rb
faraday-2.12.2 lib/faraday/options/proxy_options.rb
faraday-2.12.1 lib/faraday/options/proxy_options.rb
moneykit-0.1.15 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
moneykit-0.1.14 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
faraday-2.12.0 lib/faraday/options/proxy_options.rb
faraday-2.11.0 lib/faraday/options/proxy_options.rb
moneykit-0.1.13 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
moneykit-0.1.12 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
moneykit-0.1.11 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
faraday-2.10.1 lib/faraday/options/proxy_options.rb
faraday-2.10.0 lib/faraday/options/proxy_options.rb
faraday-2.9.2 lib/faraday/options/proxy_options.rb
faraday-2.9.1 lib/faraday/options/proxy_options.rb
moneykit-0.1.10 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
moneykit-0.1.9 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
moneykit-0.1.6 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
moneykit-0.1.5 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
moneykit-0.1.4 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb
moneykit-0.1.3 vendor/bundle/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/options/proxy_options.rb