Class: Faraday::ProxyOptions

Inherits:
Options
  • Object
show all
Defined in:
lib/faraday/options/proxy_options.rb

Overview

ProxyOptions contains the configurable properties for the proxy configuration used when making an HTTP request.

Instance Attribute Summary collapse

Method Summary

Methods inherited from Options

#[], attribute_options, #clear, #deep_dup, #delete, #each, #each_key, #each_value, #empty?, #fetch, fetch_error_class, from, inherited, #inspect, #key?, #keys, memoized, memoized_attributes, #merge, #merge!, options, options_for, #symbolized_key_set, #to_hash, #update, #value?, #values_at

Instance Attribute Details

#passwordString

Returns the proxy server password.

Returns:

  • (String)

    the proxy server password



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/faraday/options/proxy_options.rb', line 17

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 value[:uri]
        value = value.dup.tap do |duped|
          duped[:uri] = Utils.URI(duped[:uri])
        end
      end
    end

    super
  end

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

#uriURI

Returns the proxy server URI.

Returns:

  • (URI)

    the proxy server URI



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/faraday/options/proxy_options.rb', line 17

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 value[:uri]
        value = value.dup.tap do |duped|
          duped[:uri] = Utils.URI(duped[:uri])
        end
      end
    end

    super
  end

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

#userString

Returns the proxy server username.

Returns:

  • (String)

    the proxy server username



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/faraday/options/proxy_options.rb', line 17

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 value[:uri]
        value = value.dup.tap do |duped|
          duped[:uri] = Utils.URI(duped[:uri])
        end
      end
    end

    super
  end

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