faraday 0.15.4 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +380 -0
  3. data/LICENSE.md +1 -1
  4. data/README.md +16 -344
  5. data/Rakefile +7 -0
  6. data/examples/client_spec.rb +65 -0
  7. data/examples/client_test.rb +79 -0
  8. data/lib/faraday.rb +127 -190
  9. data/lib/faraday/adapter.rb +72 -22
  10. data/lib/faraday/adapter/test.rb +86 -53
  11. data/lib/faraday/adapter/typhoeus.rb +4 -1
  12. data/lib/faraday/adapter_registry.rb +30 -0
  13. data/lib/faraday/autoload.rb +39 -36
  14. data/lib/faraday/connection.rb +320 -183
  15. data/lib/faraday/dependency_loader.rb +37 -0
  16. data/lib/faraday/encoders/flat_params_encoder.rb +105 -0
  17. data/lib/faraday/encoders/nested_params_encoder.rb +176 -0
  18. data/lib/faraday/error.rb +123 -37
  19. data/lib/faraday/file_part.rb +128 -0
  20. data/lib/faraday/logging/formatter.rb +105 -0
  21. data/lib/faraday/methods.rb +6 -0
  22. data/lib/faraday/middleware.rb +19 -25
  23. data/lib/faraday/middleware_registry.rb +129 -0
  24. data/lib/faraday/options.rb +39 -194
  25. data/lib/faraday/options/connection_options.rb +22 -0
  26. data/lib/faraday/options/env.rb +181 -0
  27. data/lib/faraday/options/proxy_options.rb +32 -0
  28. data/lib/faraday/options/request_options.rb +22 -0
  29. data/lib/faraday/options/ssl_options.rb +59 -0
  30. data/lib/faraday/param_part.rb +53 -0
  31. data/lib/faraday/parameters.rb +4 -197
  32. data/lib/faraday/rack_builder.rb +77 -65
  33. data/lib/faraday/request.rb +86 -44
  34. data/lib/faraday/request/authorization.rb +44 -30
  35. data/lib/faraday/request/basic_authentication.rb +14 -7
  36. data/lib/faraday/request/instrumentation.rb +45 -27
  37. data/lib/faraday/request/multipart.rb +86 -48
  38. data/lib/faraday/request/retry.rb +198 -169
  39. data/lib/faraday/request/token_authentication.rb +15 -10
  40. data/lib/faraday/request/url_encoded.rb +43 -23
  41. data/lib/faraday/response.rb +27 -23
  42. data/lib/faraday/response/logger.rb +22 -69
  43. data/lib/faraday/response/raise_error.rb +49 -14
  44. data/lib/faraday/utils.rb +38 -247
  45. data/lib/faraday/utils/headers.rb +139 -0
  46. data/lib/faraday/utils/params_hash.rb +61 -0
  47. data/lib/faraday/version.rb +5 -0
  48. data/spec/external_adapters/faraday_specs_setup.rb +14 -0
  49. data/spec/faraday/adapter/em_http_spec.rb +49 -0
  50. data/spec/faraday/adapter/em_synchrony_spec.rb +18 -0
  51. data/spec/faraday/adapter/excon_spec.rb +49 -0
  52. data/spec/faraday/adapter/httpclient_spec.rb +73 -0
  53. data/spec/faraday/adapter/net_http_spec.rb +64 -0
  54. data/spec/faraday/adapter/patron_spec.rb +18 -0
  55. data/spec/faraday/adapter/rack_spec.rb +8 -0
  56. data/spec/faraday/adapter/test_spec.rb +260 -0
  57. data/spec/faraday/adapter/typhoeus_spec.rb +7 -0
  58. data/spec/faraday/adapter_registry_spec.rb +28 -0
  59. data/spec/faraday/adapter_spec.rb +55 -0
  60. data/spec/faraday/composite_read_io_spec.rb +80 -0
  61. data/spec/faraday/connection_spec.rb +736 -0
  62. data/spec/faraday/error_spec.rb +60 -0
  63. data/spec/faraday/middleware_spec.rb +52 -0
  64. data/spec/faraday/options/env_spec.rb +70 -0
  65. data/spec/faraday/options/options_spec.rb +297 -0
  66. data/spec/faraday/options/proxy_options_spec.rb +44 -0
  67. data/spec/faraday/options/request_options_spec.rb +19 -0
  68. data/spec/faraday/params_encoders/flat_spec.rb +42 -0
  69. data/spec/faraday/params_encoders/nested_spec.rb +142 -0
  70. data/spec/faraday/rack_builder_spec.rb +345 -0
  71. data/spec/faraday/request/authorization_spec.rb +88 -0
  72. data/spec/faraday/request/instrumentation_spec.rb +76 -0
  73. data/spec/faraday/request/multipart_spec.rb +302 -0
  74. data/spec/faraday/request/retry_spec.rb +242 -0
  75. data/spec/faraday/request/url_encoded_spec.rb +83 -0
  76. data/spec/faraday/request_spec.rb +120 -0
  77. data/spec/faraday/response/logger_spec.rb +220 -0
  78. data/spec/faraday/response/middleware_spec.rb +68 -0
  79. data/spec/faraday/response/raise_error_spec.rb +169 -0
  80. data/spec/faraday/response_spec.rb +75 -0
  81. data/spec/faraday/utils/headers_spec.rb +82 -0
  82. data/spec/faraday/utils_spec.rb +56 -0
  83. data/spec/faraday_spec.rb +37 -0
  84. data/spec/spec_helper.rb +132 -0
  85. data/spec/support/disabling_stub.rb +14 -0
  86. data/spec/support/fake_safe_buffer.rb +15 -0
  87. data/spec/support/helper_methods.rb +133 -0
  88. data/spec/support/shared_examples/adapter.rb +105 -0
  89. data/spec/support/shared_examples/params_encoder.rb +18 -0
  90. data/spec/support/shared_examples/request_method.rb +262 -0
  91. data/spec/support/streaming_response_checker.rb +35 -0
  92. data/spec/support/webmock_rack_app.rb +68 -0
  93. metadata +206 -19
  94. data/lib/faraday/adapter/em_http.rb +0 -243
  95. data/lib/faraday/adapter/em_http_ssl_patch.rb +0 -56
  96. data/lib/faraday/adapter/em_synchrony.rb +0 -106
  97. data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +0 -66
  98. data/lib/faraday/adapter/excon.rb +0 -82
  99. data/lib/faraday/adapter/httpclient.rb +0 -128
  100. data/lib/faraday/adapter/net_http.rb +0 -152
  101. data/lib/faraday/adapter/net_http_persistent.rb +0 -68
  102. data/lib/faraday/adapter/patron.rb +0 -95
  103. data/lib/faraday/adapter/rack.rb +0 -58
  104. data/lib/faraday/upload_io.rb +0 -67
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Requires Ruby with rspec and faraday gems.
4
+ # rspec client_spec.rb
5
+
6
+ require 'faraday'
7
+ require 'json'
8
+
9
+ # Example API client
10
+ class Client
11
+ def initialize(conn)
12
+ @conn = conn
13
+ end
14
+
15
+ def sushi(jname)
16
+ res = @conn.get("/#{jname}")
17
+ data = JSON.parse(res.body)
18
+ data['name']
19
+ end
20
+ end
21
+
22
+ RSpec.describe Client do
23
+ let(:stubs) { Faraday::Adapter::Test::Stubs.new }
24
+ let(:conn) { Faraday.new { |b| b.adapter(:test, stubs) } }
25
+ let(:client) { Client.new(conn) }
26
+
27
+ it 'parses name' do
28
+ stubs.get('/ebi') do |env|
29
+ # optional: you can inspect the Faraday::Env
30
+ expect(env.url.path).to eq('/ebi')
31
+ [
32
+ 200,
33
+ { 'Content-Type': 'application/javascript' },
34
+ '{"name": "shrimp"}'
35
+ ]
36
+ end
37
+
38
+ # uncomment to trigger stubs.verify_stubbed_calls failure
39
+ # stubs.get('/unused') { [404, {}, ''] }
40
+
41
+ expect(client.sushi('ebi')).to eq('shrimp')
42
+ stubs.verify_stubbed_calls
43
+ end
44
+
45
+ it 'handles 404' do
46
+ stubs.get('/ebi') do
47
+ [
48
+ 404,
49
+ { 'Content-Type': 'application/javascript' },
50
+ '{}'
51
+ ]
52
+ end
53
+ expect(client.sushi('ebi')).to be_nil
54
+ stubs.verify_stubbed_calls
55
+ end
56
+
57
+ it 'handles exception' do
58
+ stubs.get('/ebi') do
59
+ raise Faraday::ConnectionFailed, nil
60
+ end
61
+
62
+ expect { client.sushi('ebi') }.to raise_error(Faraday::ConnectionFailed)
63
+ stubs.verify_stubbed_calls
64
+ end
65
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Requires Ruby with test-unit and faraday gems.
4
+ # ruby client_test.rb
5
+
6
+ require 'faraday'
7
+ require 'json'
8
+ require 'test/unit'
9
+
10
+ # Example API client
11
+ class Client
12
+ def initialize(conn)
13
+ @conn = conn
14
+ end
15
+
16
+ def sushi(jname)
17
+ res = @conn.get("/#{jname}")
18
+ data = JSON.parse(res.body)
19
+ data['name']
20
+ end
21
+ end
22
+
23
+ # Example API client test
24
+ class ClientTest < Test::Unit::TestCase
25
+ def test_sushi_name
26
+ stubs = Faraday::Adapter::Test::Stubs.new
27
+ stubs.get('/ebi') do |env|
28
+ # optional: you can inspect the Faraday::Env
29
+ assert_equal '/ebi', env.url.path
30
+ [
31
+ 200,
32
+ { 'Content-Type': 'application/javascript' },
33
+ '{"name": "shrimp"}'
34
+ ]
35
+ end
36
+
37
+ # uncomment to trigger stubs.verify_stubbed_calls failure
38
+ # stubs.get('/unused') { [404, {}, ''] }
39
+
40
+ cli = client(stubs)
41
+ assert_equal 'shrimp', cli.sushi('ebi')
42
+ stubs.verify_stubbed_calls
43
+ end
44
+
45
+ def test_sushi_404
46
+ stubs = Faraday::Adapter::Test::Stubs.new
47
+ stubs.get('/ebi') do
48
+ [
49
+ 404,
50
+ { 'Content-Type': 'application/javascript' },
51
+ '{}'
52
+ ]
53
+ end
54
+
55
+ cli = client(stubs)
56
+ assert_nil cli.sushi('ebi')
57
+ stubs.verify_stubbed_calls
58
+ end
59
+
60
+ def test_sushi_exception
61
+ stubs = Faraday::Adapter::Test::Stubs.new
62
+ stubs.get('/ebi') do
63
+ raise Faraday::ConnectionFailed, nil
64
+ end
65
+
66
+ cli = client(stubs)
67
+ assert_raise Faraday::ConnectionFailed do
68
+ cli.sushi('ebi')
69
+ end
70
+ stubs.verify_stubbed_calls
71
+ end
72
+
73
+ def client(stubs)
74
+ conn = Faraday.new do |builder|
75
+ builder.adapter :test, stubs
76
+ end
77
+ Client.new(conn)
78
+ end
79
+ end
data/lib/faraday.rb CHANGED
@@ -1,248 +1,185 @@
1
- require 'thread'
1
+ # frozen_string_literal: true
2
+
2
3
  require 'cgi'
4
+ require 'date'
3
5
  require 'set'
4
6
  require 'forwardable'
7
+ require 'faraday/middleware_registry'
8
+ require 'faraday/dependency_loader'
9
+
10
+ unless defined?(::Faraday::Timer)
11
+ require 'timeout'
12
+ ::Faraday::Timer = Timeout
13
+ end
5
14
 
6
- # Public: This is the main namespace for Faraday. You can either use it to
7
- # create Faraday::Connection objects, or access it directly.
15
+ require 'faraday/version'
16
+ require 'faraday/methods'
17
+ require 'faraday/utils'
18
+ require 'faraday/options'
19
+ require 'faraday/connection'
20
+ require 'faraday/rack_builder'
21
+ require 'faraday/parameters'
22
+ require 'faraday/middleware'
23
+ require 'faraday/adapter'
24
+ require 'faraday/request'
25
+ require 'faraday/response'
26
+ require 'faraday/error'
27
+ require 'faraday/file_part'
28
+ require 'faraday/param_part'
29
+
30
+ unless defined?(JRUBY_VERSION)
31
+ require 'faraday/em_http'
32
+ require 'faraday/em_synchrony'
33
+ end
34
+ require 'faraday/excon'
35
+ require 'faraday/httpclient'
36
+ require 'faraday/net_http'
37
+ require 'faraday/net_http_persistent'
38
+ require 'faraday/patron'
39
+ require 'faraday/rack'
40
+
41
+ # This is the main namespace for Faraday.
8
42
  #
9
- # Examples
43
+ # It provides methods to create {Connection} objects, and HTTP-related
44
+ # methods to use directly.
10
45
  #
46
+ # @example Helpful class methods for easy usage
11
47
  # Faraday.get "http://faraday.com"
12
48
  #
49
+ # @example Helpful class method `.new` to create {Connection} objects.
13
50
  # conn = Faraday.new "http://faraday.com"
14
51
  # conn.get '/'
15
52
  #
16
53
  module Faraday
17
- VERSION = "0.15.4"
18
-
19
54
  class << self
20
- # Public: Gets or sets the root path that Faraday is being loaded from.
21
- # This is the root from where the libraries are auto-loaded from.
55
+ # The root path that Faraday is being loaded from.
56
+ #
57
+ # This is the root from where the libraries are auto-loaded.
58
+ #
59
+ # @return [String]
22
60
  attr_accessor :root_path
23
61
 
24
- # Public: Gets or sets the path that the Faraday libs are loaded from.
62
+ # Gets or sets the path that the Faraday libs are loaded from.
63
+ # @return [String]
25
64
  attr_accessor :lib_path
26
65
 
27
- # Public: Gets or sets the Symbol key identifying a default Adapter to use
28
- # for the default Faraday::Connection.
66
+ # @overload default_adapter
67
+ # Gets the Symbol key identifying a default Adapter to use
68
+ # for the default {Faraday::Connection}. Defaults to `:net_http`.
69
+ # @return [Symbol] the default adapter
70
+ # @overload default_adapter=(adapter)
71
+ # Updates default adapter while resetting {.default_connection}.
72
+ # @return [Symbol] the new default_adapter.
29
73
  attr_reader :default_adapter
30
74
 
31
- # Public: Sets the default Faraday::Connection for simple scripts that
32
- # access the Faraday constant directly.
33
- #
34
- # Faraday.get "https://faraday.com"
75
+ # Documented below, see default_connection
35
76
  attr_writer :default_connection
36
77
 
37
- # Public: Tells faraday to ignore the environment proxy (http_proxy).
78
+ # Tells Faraday to ignore the environment proxy (http_proxy).
79
+ # Defaults to `false`.
80
+ # @return [Boolean]
38
81
  attr_accessor :ignore_env_proxy
39
82
 
40
- # Public: Initializes a new Faraday::Connection.
41
- #
42
- # url - The optional String base URL to use as a prefix for all
43
- # requests. Can also be the options Hash.
44
- # options - The optional Hash used to configure this Faraday::Connection.
45
- # Any of these values will be set on every request made, unless
46
- # overridden for a specific request.
47
- # :url - String base URL.
48
- # :params - Hash of URI query unencoded key/value pairs.
49
- # :headers - Hash of unencoded HTTP header key/value pairs.
50
- # :request - Hash of request options.
51
- # :ssl - Hash of SSL options.
52
- # :proxy - Hash of Proxy options.
53
- #
54
- # Examples
55
- #
83
+ # Initializes a new {Connection}.
84
+ #
85
+ # @param url [String,Hash] The optional String base URL to use as a prefix
86
+ # for all requests. Can also be the options Hash. Any of these
87
+ # values will be set on every request made, unless overridden
88
+ # for a specific request.
89
+ # @param options [Hash]
90
+ # @option options [String] :url Base URL
91
+ # @option options [Hash] :params Hash of unencoded URI query params.
92
+ # @option options [Hash] :headers Hash of unencoded HTTP headers.
93
+ # @option options [Hash] :request Hash of request options.
94
+ # @option options [Hash] :ssl Hash of SSL options.
95
+ # @option options [Hash] :proxy Hash of Proxy options.
96
+ # @return [Faraday::Connection]
97
+ #
98
+ # @example With an URL argument
56
99
  # Faraday.new 'http://faraday.com'
57
- #
58
- # # http://faraday.com?page=1
59
- # Faraday.new 'http://faraday.com', :params => {:page => 1}
60
- #
61
- # # same
62
- #
63
- # Faraday.new :url => 'http://faraday.com',
64
- # :params => {:page => 1}
65
- #
66
- # Returns a Faraday::Connection.
67
- def new(url = nil, options = nil)
68
- block = block_given? ? Proc.new : nil
69
- options = options ? default_connection_options.merge(options) : default_connection_options
100
+ # # => Faraday::Connection to http://faraday.com
101
+ #
102
+ # @example With an URL argument and an options hash
103
+ # Faraday.new 'http://faraday.com', params: { page: 1 }
104
+ # # => Faraday::Connection to http://faraday.com?page=1
105
+ #
106
+ # @example With everything in an options hash
107
+ # Faraday.new url: 'http://faraday.com',
108
+ # params: { page: 1 }
109
+ # # => Faraday::Connection to http://faraday.com?page=1
110
+ def new(url = nil, options = {}, &block)
111
+ options = default_connection_options.merge(options)
70
112
  Faraday::Connection.new(url, options, &block)
71
113
  end
72
114
 
115
+ # @private
73
116
  # Internal: Requires internal Faraday libraries.
74
117
  #
75
- # *libs - One or more relative String names to Faraday classes.
76
- #
77
- # Returns nothing.
118
+ # @param libs [Array] one or more relative String names to Faraday classes.
119
+ # @return [void]
78
120
  def require_libs(*libs)
79
121
  libs.each do |lib|
80
122
  require "#{lib_path}/#{lib}"
81
123
  end
82
124
  end
83
125
 
84
- # Public: Updates default adapter while resetting
85
- # #default_connection.
86
- #
87
- # Returns the new default_adapter.
126
+ alias require_lib require_libs
127
+
128
+ # Documented elsewhere, see default_adapter reader
88
129
  def default_adapter=(adapter)
89
130
  @default_connection = nil
90
131
  @default_adapter = adapter
91
132
  end
92
133
 
93
- alias require_lib require_libs
94
-
95
- def respond_to?(symbol, include_private = false)
134
+ def respond_to_missing?(symbol, include_private = false)
96
135
  default_connection.respond_to?(symbol, include_private) || super
97
136
  end
98
137
 
99
- private
100
- # Internal: Proxies method calls on the Faraday constant to
101
- # #default_connection.
102
- def method_missing(name, *args, &block)
103
- default_connection.send(name, *args, &block)
138
+ # @overload default_connection
139
+ # Gets the default connection used for simple scripts.
140
+ # @return [Faraday::Connection] a connection configured with
141
+ # the default_adapter.
142
+ # @overload default_connection=(connection)
143
+ # @param connection [Faraday::Connection]
144
+ # Sets the default {Faraday::Connection} for simple scripts that
145
+ # access the Faraday constant directly, such as
146
+ # <code>Faraday.get "https://faraday.com"</code>.
147
+ def default_connection
148
+ @default_connection ||= Connection.new(default_connection_options)
104
149
  end
105
- end
106
-
107
- self.ignore_env_proxy = false
108
- self.root_path = File.expand_path "..", __FILE__
109
- self.lib_path = File.expand_path "../faraday", __FILE__
110
- self.default_adapter = :net_http
111
150
 
112
- # Gets the default connection used for simple scripts.
113
- #
114
- # Returns a Faraday::Connection, configured with the #default_adapter.
115
- def self.default_connection
116
- @default_connection ||= Connection.new(default_connection_options)
117
- end
118
-
119
- # Gets the default connection options used when calling Faraday#new.
120
- #
121
- # Returns a Faraday::ConnectionOptions.
122
- def self.default_connection_options
123
- @default_connection_options ||= ConnectionOptions.new
124
- end
125
-
126
- # Public: Sets the default options used when calling Faraday#new.
127
- def self.default_connection_options=(options)
128
- @default_connection = nil
129
- @default_connection_options = ConnectionOptions.from(options)
130
- end
131
-
132
- unless const_defined? :Timer
133
- require 'timeout'
134
- Timer = Timeout
135
- end
136
-
137
- # Public: Adds the ability for other modules to register and lookup
138
- # middleware classes.
139
- module MiddlewareRegistry
140
- # Public: Register middleware class(es) on the current module.
141
- #
142
- # mapping - A Hash mapping Symbol keys to classes. Classes can be expressed
143
- # as fully qualified constant, or a Proc that will be lazily
144
- # called to return the former.
145
- #
146
- # Examples
147
- #
148
- # module Faraday
149
- # class Whatever
150
- # # Middleware looked up by :foo returns Faraday::Whatever::Foo.
151
- # register_middleware :foo => Foo
151
+ # Gets the default connection options used when calling {Faraday#new}.
152
152
  #
153
- # # Middleware looked up by :bar returns Faraday::Whatever.const_get(:Bar)
154
- # register_middleware :bar => :Bar
155
- #
156
- # # Middleware looked up by :baz requires 'baz' and returns Faraday::Whatever.const_get(:Baz)
157
- # register_middleware :baz => [:Baz, 'baz']
158
- # end
159
- # end
160
- #
161
- # Returns nothing.
162
- def register_middleware(autoload_path = nil, mapping = nil)
163
- if mapping.nil?
164
- mapping = autoload_path
165
- autoload_path = nil
166
- end
167
- middleware_mutex do
168
- @middleware_autoload_path = autoload_path if autoload_path
169
- (@registered_middleware ||= {}).update(mapping)
170
- end
153
+ # @return [Faraday::ConnectionOptions]
154
+ def default_connection_options
155
+ @default_connection_options ||= ConnectionOptions.new
171
156
  end
172
157
 
173
- # Public: Lookup middleware class with a registered Symbol shortcut.
174
- #
175
- # key - The Symbol key for the registered middleware.
176
- #
177
- # Examples
178
- #
179
- # module Faraday
180
- # class Whatever
181
- # register_middleware :foo => Foo
182
- # end
183
- # end
158
+ # Sets the default options used when calling {Faraday#new}.
184
159
  #
185
- # Faraday::Whatever.lookup_middleware(:foo)
186
- # # => Faraday::Whatever::Foo
187
- #
188
- # Returns a middleware Class.
189
- def lookup_middleware(key)
190
- load_middleware(key) ||
191
- raise(Faraday::Error.new("#{key.inspect} is not registered on #{self}"))
192
- end
193
-
194
- def middleware_mutex(&block)
195
- @middleware_mutex ||= begin
196
- require 'monitor'
197
- Monitor.new
198
- end
199
- @middleware_mutex.synchronize(&block)
160
+ # @param options [Hash, Faraday::ConnectionOptions]
161
+ def default_connection_options=(options)
162
+ @default_connection = nil
163
+ @default_connection_options = ConnectionOptions.from(options)
200
164
  end
201
165
 
202
- def fetch_middleware(key)
203
- defined?(@registered_middleware) && @registered_middleware[key]
204
- end
166
+ private
205
167
 
206
- def load_middleware(key)
207
- value = fetch_middleware(key)
208
- case value
209
- when Module
210
- value
211
- when Symbol, String
212
- middleware_mutex do
213
- @registered_middleware[key] = const_get(value)
214
- end
215
- when Proc
216
- middleware_mutex do
217
- @registered_middleware[key] = value.call
218
- end
219
- when Array
220
- middleware_mutex do
221
- const, path = value
222
- if root = @middleware_autoload_path
223
- path = "#{root}/#{path}"
224
- end
225
- require(path)
226
- @registered_middleware[key] = const
227
- end
228
- load_middleware(key)
168
+ # Internal: Proxies method calls on the Faraday constant to
169
+ # .default_connection.
170
+ def method_missing(name, *args, &block)
171
+ if default_connection.respond_to?(name)
172
+ default_connection.send(name, *args, &block)
173
+ else
174
+ super
229
175
  end
230
176
  end
231
177
  end
232
178
 
233
- def self.const_missing(name)
234
- if name.to_sym == :Builder
235
- warn "Faraday::Builder is now Faraday::RackBuilder."
236
- const_set name, RackBuilder
237
- else
238
- super
239
- end
240
- end
241
-
242
- require_libs "utils", "options", "connection", "rack_builder", "parameters",
243
- "middleware", "adapter", "request", "response", "upload_io", "error"
179
+ self.ignore_env_proxy = false
180
+ self.root_path = File.expand_path __dir__
181
+ self.lib_path = File.expand_path 'faraday', __dir__
182
+ self.default_adapter = :net_http
244
183
 
245
- if !ENV["FARADAY_NO_AUTOLOAD"]
246
- require_lib 'autoload'
247
- end
184
+ require_lib 'autoload' unless ENV['FARADAY_NO_AUTOLOAD']
248
185
  end