faraday 0.17.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +52 -8
 - data/LICENSE.md +1 -1
 - data/README.md +17 -358
 - data/Rakefile +1 -7
 - data/examples/client_spec.rb +65 -0
 - data/examples/client_test.rb +79 -0
 - data/lib/faraday.rb +116 -189
 - data/lib/faraday/adapter.rb +83 -22
 - data/lib/faraday/adapter/em_http.rb +148 -102
 - data/lib/faraday/adapter/em_http_ssl_patch.rb +24 -18
 - data/lib/faraday/adapter/em_synchrony.rb +110 -63
 - data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +18 -15
 - data/lib/faraday/adapter/excon.rb +98 -56
 - data/lib/faraday/adapter/httpclient.rb +83 -59
 - data/lib/faraday/adapter/net_http.rb +137 -69
 - data/lib/faraday/adapter/net_http_persistent.rb +50 -27
 - data/lib/faraday/adapter/patron.rb +80 -43
 - data/lib/faraday/adapter/rack.rb +30 -13
 - data/lib/faraday/adapter/test.rb +86 -53
 - data/lib/faraday/adapter/typhoeus.rb +4 -1
 - data/lib/faraday/adapter_registry.rb +30 -0
 - data/lib/faraday/autoload.rb +47 -36
 - data/lib/faraday/connection.rb +312 -182
 - data/lib/faraday/dependency_loader.rb +37 -0
 - data/lib/faraday/encoders/flat_params_encoder.rb +105 -0
 - data/lib/faraday/encoders/nested_params_encoder.rb +176 -0
 - data/lib/faraday/error.rb +17 -35
 - data/lib/faraday/file_part.rb +128 -0
 - data/lib/faraday/logging/formatter.rb +105 -0
 - data/lib/faraday/methods.rb +6 -0
 - data/lib/faraday/middleware.rb +19 -25
 - data/lib/faraday/middleware_registry.rb +129 -0
 - data/lib/faraday/options.rb +36 -191
 - data/lib/faraday/options/connection_options.rb +22 -0
 - data/lib/faraday/options/env.rb +181 -0
 - data/lib/faraday/options/proxy_options.rb +28 -0
 - data/lib/faraday/options/request_options.rb +22 -0
 - data/lib/faraday/options/ssl_options.rb +59 -0
 - data/lib/faraday/param_part.rb +53 -0
 - data/lib/faraday/parameters.rb +4 -197
 - data/lib/faraday/rack_builder.rb +76 -64
 - data/lib/faraday/request.rb +86 -44
 - data/lib/faraday/request/authorization.rb +44 -30
 - data/lib/faraday/request/basic_authentication.rb +14 -7
 - data/lib/faraday/request/instrumentation.rb +45 -27
 - data/lib/faraday/request/multipart.rb +86 -48
 - data/lib/faraday/request/retry.rb +197 -171
 - data/lib/faraday/request/token_authentication.rb +15 -10
 - data/lib/faraday/request/url_encoded.rb +43 -23
 - data/lib/faraday/response.rb +24 -20
 - data/lib/faraday/response/logger.rb +22 -69
 - data/lib/faraday/response/raise_error.rb +49 -18
 - data/lib/faraday/utils.rb +38 -247
 - data/lib/faraday/utils/headers.rb +139 -0
 - data/lib/faraday/utils/params_hash.rb +61 -0
 - data/lib/faraday/version.rb +5 -0
 - data/spec/external_adapters/faraday_specs_setup.rb +14 -0
 - data/spec/faraday/adapter/em_http_spec.rb +47 -0
 - data/spec/faraday/adapter/em_synchrony_spec.rb +16 -0
 - data/spec/faraday/adapter/excon_spec.rb +49 -0
 - data/spec/faraday/adapter/httpclient_spec.rb +73 -0
 - data/spec/faraday/adapter/net_http_persistent_spec.rb +57 -0
 - data/spec/faraday/adapter/net_http_spec.rb +64 -0
 - data/spec/faraday/adapter/patron_spec.rb +18 -0
 - data/spec/faraday/adapter/rack_spec.rb +8 -0
 - data/spec/faraday/adapter/test_spec.rb +260 -0
 - data/spec/faraday/adapter/typhoeus_spec.rb +7 -0
 - data/spec/faraday/adapter_registry_spec.rb +28 -0
 - data/spec/faraday/adapter_spec.rb +55 -0
 - data/spec/faraday/composite_read_io_spec.rb +80 -0
 - data/spec/faraday/connection_spec.rb +691 -0
 - data/spec/faraday/error_spec.rb +0 -57
 - data/spec/faraday/middleware_spec.rb +52 -0
 - data/spec/faraday/options/env_spec.rb +70 -0
 - data/spec/faraday/options/options_spec.rb +297 -0
 - data/spec/faraday/options/proxy_options_spec.rb +37 -0
 - data/spec/faraday/options/request_options_spec.rb +19 -0
 - data/spec/faraday/params_encoders/flat_spec.rb +42 -0
 - data/spec/faraday/params_encoders/nested_spec.rb +142 -0
 - data/spec/faraday/rack_builder_spec.rb +345 -0
 - data/spec/faraday/request/authorization_spec.rb +88 -0
 - data/spec/faraday/request/instrumentation_spec.rb +76 -0
 - data/spec/faraday/request/multipart_spec.rb +302 -0
 - data/spec/faraday/request/retry_spec.rb +242 -0
 - data/spec/faraday/request/url_encoded_spec.rb +83 -0
 - data/spec/faraday/request_spec.rb +120 -0
 - data/spec/faraday/response/logger_spec.rb +220 -0
 - data/spec/faraday/response/middleware_spec.rb +68 -0
 - data/spec/faraday/response/raise_error_spec.rb +48 -15
 - data/spec/faraday/response_spec.rb +75 -0
 - data/spec/faraday/utils/headers_spec.rb +82 -0
 - data/spec/faraday/utils_spec.rb +56 -0
 - data/spec/faraday_spec.rb +37 -0
 - data/spec/spec_helper.rb +63 -36
 - data/spec/support/disabling_stub.rb +14 -0
 - data/spec/support/fake_safe_buffer.rb +15 -0
 - data/spec/support/helper_methods.rb +133 -0
 - data/spec/support/shared_examples/adapter.rb +105 -0
 - data/spec/support/shared_examples/params_encoder.rb +18 -0
 - data/spec/support/shared_examples/request_method.rb +262 -0
 - data/spec/support/streaming_response_checker.rb +35 -0
 - data/spec/support/webmock_rack_app.rb +68 -0
 - metadata +83 -38
 - data/lib/faraday/deprecate.rb +0 -107
 - data/lib/faraday/upload_io.rb +0 -67
 - data/spec/faraday/deprecate_spec.rb +0 -69
 - data/test/adapters/default_test.rb +0 -14
 - data/test/adapters/em_http_test.rb +0 -30
 - data/test/adapters/em_synchrony_test.rb +0 -32
 - data/test/adapters/excon_test.rb +0 -30
 - data/test/adapters/httpclient_test.rb +0 -34
 - data/test/adapters/integration.rb +0 -263
 - data/test/adapters/logger_test.rb +0 -136
 - data/test/adapters/net_http_persistent_test.rb +0 -114
 - data/test/adapters/net_http_test.rb +0 -79
 - data/test/adapters/patron_test.rb +0 -40
 - data/test/adapters/rack_test.rb +0 -38
 - data/test/adapters/test_middleware_test.rb +0 -157
 - data/test/adapters/typhoeus_test.rb +0 -38
 - data/test/authentication_middleware_test.rb +0 -65
 - data/test/composite_read_io_test.rb +0 -109
 - data/test/connection_test.rb +0 -738
 - data/test/env_test.rb +0 -268
 - data/test/helper.rb +0 -75
 - data/test/live_server.rb +0 -67
 - data/test/middleware/instrumentation_test.rb +0 -88
 - data/test/middleware/retry_test.rb +0 -282
 - data/test/middleware_stack_test.rb +0 -260
 - data/test/multibyte.txt +0 -1
 - data/test/options_test.rb +0 -333
 - data/test/parameters_test.rb +0 -157
 - data/test/request_middleware_test.rb +0 -126
 - data/test/response_middleware_test.rb +0 -72
 - data/test/strawberry.rb +0 -2
 - data/test/utils_test.rb +0 -98
 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,13 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            require 'rake/testtask'
         
     | 
| 
       4 
3 
     | 
    
         
             
            require 'rspec/core/rake_task'
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
5 
     | 
    
         
             
            RSpec::Core::RakeTask.new(:spec)
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            task : 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            desc "Run all tests"
         
     | 
| 
       11 
     | 
    
         
            -
            task :test => :spec do
         
     | 
| 
       12 
     | 
    
         
            -
              exec 'script/test'
         
     | 
| 
       13 
     | 
    
         
            -
            end
         
     | 
| 
      
 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,247 +1,174 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            +
              Timer = Timeout
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
       5 
14 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            +
            # This is the main namespace for Faraday.
         
     | 
| 
       8 
31 
     | 
    
         
             
            #
         
     | 
| 
       9 
     | 
    
         
            -
            #  
     | 
| 
      
 32 
     | 
    
         
            +
            # It provides methods to create {Connection} objects, and HTTP-related
         
     | 
| 
      
 33 
     | 
    
         
            +
            # methods to use directly.
         
     | 
| 
       10 
34 
     | 
    
         
             
            #
         
     | 
| 
      
 35 
     | 
    
         
            +
            # @example Helpful class methods for easy usage
         
     | 
| 
       11 
36 
     | 
    
         
             
            #   Faraday.get "http://faraday.com"
         
     | 
| 
       12 
37 
     | 
    
         
             
            #
         
     | 
| 
      
 38 
     | 
    
         
            +
            # @example Helpful class method `.new` to create {Connection} objects.
         
     | 
| 
       13 
39 
     | 
    
         
             
            #   conn = Faraday.new "http://faraday.com"
         
     | 
| 
       14 
40 
     | 
    
         
             
            #   conn.get '/'
         
     | 
| 
       15 
41 
     | 
    
         
             
            #
         
     | 
| 
       16 
42 
     | 
    
         
             
            module Faraday
         
     | 
| 
       17 
     | 
    
         
            -
              VERSION = "0.17.3"
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
43 
     | 
    
         
             
              class << self
         
     | 
| 
       20 
     | 
    
         
            -
                #  
     | 
| 
       21 
     | 
    
         
            -
                # 
     | 
| 
      
 44 
     | 
    
         
            +
                # The root path that Faraday is being loaded from.
         
     | 
| 
      
 45 
     | 
    
         
            +
                #
         
     | 
| 
      
 46 
     | 
    
         
            +
                # This is the root from where the libraries are auto-loaded.
         
     | 
| 
      
 47 
     | 
    
         
            +
                #
         
     | 
| 
      
 48 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
       22 
49 
     | 
    
         
             
                attr_accessor :root_path
         
     | 
| 
       23 
50 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                #  
     | 
| 
      
 51 
     | 
    
         
            +
                # Gets or sets the path that the Faraday libs are loaded from.
         
     | 
| 
      
 52 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
       25 
53 
     | 
    
         
             
                attr_accessor :lib_path
         
     | 
| 
       26 
54 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                #  
     | 
| 
       28 
     | 
    
         
            -
                #  
     | 
| 
      
 55 
     | 
    
         
            +
                # @overload default_adapter
         
     | 
| 
      
 56 
     | 
    
         
            +
                #   Gets the Symbol key identifying a default Adapter to use
         
     | 
| 
      
 57 
     | 
    
         
            +
                #   for the default {Faraday::Connection}. Defaults to `:net_http`.
         
     | 
| 
      
 58 
     | 
    
         
            +
                #   @return [Symbol] the default adapter
         
     | 
| 
      
 59 
     | 
    
         
            +
                # @overload default_adapter=(adapter)
         
     | 
| 
      
 60 
     | 
    
         
            +
                #   Updates default adapter while resetting {.default_connection}.
         
     | 
| 
      
 61 
     | 
    
         
            +
                #   @return [Symbol] the new default_adapter.
         
     | 
| 
       29 
62 
     | 
    
         
             
                attr_reader :default_adapter
         
     | 
| 
       30 
63 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                #  
     | 
| 
       32 
     | 
    
         
            -
                # access the Faraday constant directly.
         
     | 
| 
       33 
     | 
    
         
            -
                #
         
     | 
| 
       34 
     | 
    
         
            -
                #     Faraday.get "https://faraday.com"
         
     | 
| 
      
 64 
     | 
    
         
            +
                # Documented below, see default_connection
         
     | 
| 
       35 
65 
     | 
    
         
             
                attr_writer :default_connection
         
     | 
| 
       36 
66 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                #  
     | 
| 
      
 67 
     | 
    
         
            +
                # Tells Faraday to ignore the environment proxy (http_proxy).
         
     | 
| 
      
 68 
     | 
    
         
            +
                # Defaults to `false`.
         
     | 
| 
      
 69 
     | 
    
         
            +
                # @return [Boolean]
         
     | 
| 
       38 
70 
     | 
    
         
             
                attr_accessor :ignore_env_proxy
         
     | 
| 
       39 
71 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
                #  
     | 
| 
       41 
     | 
    
         
            -
                #
         
     | 
| 
       42 
     | 
    
         
            -
                # url 
     | 
| 
       43 
     | 
    
         
            -
                #           requests.  Can also be the options Hash.
         
     | 
| 
       44 
     | 
    
         
            -
                #  
     | 
| 
       45 
     | 
    
         
            -
                #            
     | 
| 
       46 
     | 
    
         
            -
                # 
     | 
| 
       47 
     | 
    
         
            -
                # 
     | 
| 
       48 
     | 
    
         
            -
                # 
     | 
| 
       49 
     | 
    
         
            -
                # 
     | 
| 
       50 
     | 
    
         
            -
                # 
     | 
| 
       51 
     | 
    
         
            -
                # 
     | 
| 
       52 
     | 
    
         
            -
                # 
     | 
| 
       53 
     | 
    
         
            -
                #
         
     | 
| 
       54 
     | 
    
         
            -
                # 
     | 
| 
       55 
     | 
    
         
            -
                #
         
     | 
| 
      
 72 
     | 
    
         
            +
                # Initializes a new {Connection}.
         
     | 
| 
      
 73 
     | 
    
         
            +
                #
         
     | 
| 
      
 74 
     | 
    
         
            +
                # @param url [String,Hash] The optional String base URL to use as a prefix
         
     | 
| 
      
 75 
     | 
    
         
            +
                #           for all requests.  Can also be the options Hash. Any of these
         
     | 
| 
      
 76 
     | 
    
         
            +
                #           values will be set on every request made, unless overridden
         
     | 
| 
      
 77 
     | 
    
         
            +
                #           for a specific request.
         
     | 
| 
      
 78 
     | 
    
         
            +
                # @param options [Hash]
         
     | 
| 
      
 79 
     | 
    
         
            +
                # @option options [String] :url Base URL
         
     | 
| 
      
 80 
     | 
    
         
            +
                # @option options [Hash] :params Hash of unencoded URI query params.
         
     | 
| 
      
 81 
     | 
    
         
            +
                # @option options [Hash] :headers Hash of unencoded HTTP headers.
         
     | 
| 
      
 82 
     | 
    
         
            +
                # @option options [Hash] :request Hash of request options.
         
     | 
| 
      
 83 
     | 
    
         
            +
                # @option options [Hash] :ssl Hash of SSL options.
         
     | 
| 
      
 84 
     | 
    
         
            +
                # @option options [Hash] :proxy Hash of Proxy options.
         
     | 
| 
      
 85 
     | 
    
         
            +
                # @return [Faraday::Connection]
         
     | 
| 
      
 86 
     | 
    
         
            +
                #
         
     | 
| 
      
 87 
     | 
    
         
            +
                # @example With an URL argument
         
     | 
| 
       56 
88 
     | 
    
         
             
                #   Faraday.new 'http://faraday.com'
         
     | 
| 
       57 
     | 
    
         
            -
                #
         
     | 
| 
       58 
     | 
    
         
            -
                # 
     | 
| 
       59 
     | 
    
         
            -
                # 
     | 
| 
       60 
     | 
    
         
            -
                #
         
     | 
| 
       61 
     | 
    
         
            -
                #   #  
     | 
| 
       62 
     | 
    
         
            -
                #
         
     | 
| 
       63 
     | 
    
         
            -
                # 
     | 
| 
       64 
     | 
    
         
            -
                # 
     | 
| 
       65 
     | 
    
         
            -
                #
         
     | 
| 
       66 
     | 
    
         
            -
                #  
     | 
| 
       67 
     | 
    
         
            -
                def new(url = nil, options =  
     | 
| 
       68 
     | 
    
         
            -
                  options =  
     | 
| 
      
 89 
     | 
    
         
            +
                #   # => Faraday::Connection to http://faraday.com
         
     | 
| 
      
 90 
     | 
    
         
            +
                #
         
     | 
| 
      
 91 
     | 
    
         
            +
                # @example With an URL argument and an options hash
         
     | 
| 
      
 92 
     | 
    
         
            +
                #   Faraday.new 'http://faraday.com', params: { page: 1 }
         
     | 
| 
      
 93 
     | 
    
         
            +
                #   # => Faraday::Connection to http://faraday.com?page=1
         
     | 
| 
      
 94 
     | 
    
         
            +
                #
         
     | 
| 
      
 95 
     | 
    
         
            +
                # @example With everything in an options hash
         
     | 
| 
      
 96 
     | 
    
         
            +
                #   Faraday.new url: 'http://faraday.com',
         
     | 
| 
      
 97 
     | 
    
         
            +
                #               params: { page: 1 }
         
     | 
| 
      
 98 
     | 
    
         
            +
                #   # => Faraday::Connection to http://faraday.com?page=1
         
     | 
| 
      
 99 
     | 
    
         
            +
                def new(url = nil, options = {}, &block)
         
     | 
| 
      
 100 
     | 
    
         
            +
                  options = default_connection_options.merge(options)
         
     | 
| 
       69 
101 
     | 
    
         
             
                  Faraday::Connection.new(url, options, &block)
         
     | 
| 
       70 
102 
     | 
    
         
             
                end
         
     | 
| 
       71 
103 
     | 
    
         | 
| 
      
 104 
     | 
    
         
            +
                # @private
         
     | 
| 
       72 
105 
     | 
    
         
             
                # Internal: Requires internal Faraday libraries.
         
     | 
| 
       73 
106 
     | 
    
         
             
                #
         
     | 
| 
       74 
     | 
    
         
            -
                #  
     | 
| 
       75 
     | 
    
         
            -
                #
         
     | 
| 
       76 
     | 
    
         
            -
                # Returns nothing.
         
     | 
| 
      
 107 
     | 
    
         
            +
                # @param libs [Array] one or more relative String names to Faraday classes.
         
     | 
| 
      
 108 
     | 
    
         
            +
                # @return [void]
         
     | 
| 
       77 
109 
     | 
    
         
             
                def require_libs(*libs)
         
     | 
| 
       78 
110 
     | 
    
         
             
                  libs.each do |lib|
         
     | 
| 
       79 
111 
     | 
    
         
             
                    require "#{lib_path}/#{lib}"
         
     | 
| 
       80 
112 
     | 
    
         
             
                  end
         
     | 
| 
       81 
113 
     | 
    
         
             
                end
         
     | 
| 
       82 
114 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
                 
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
                #
         
     | 
| 
       86 
     | 
    
         
            -
                # Returns the new default_adapter.
         
     | 
| 
      
 115 
     | 
    
         
            +
                alias require_lib require_libs
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                # Documented elsewhere, see default_adapter reader
         
     | 
| 
       87 
118 
     | 
    
         
             
                def default_adapter=(adapter)
         
     | 
| 
       88 
119 
     | 
    
         
             
                  @default_connection = nil
         
     | 
| 
       89 
120 
     | 
    
         
             
                  @default_adapter = adapter
         
     | 
| 
       90 
121 
     | 
    
         
             
                end
         
     | 
| 
       91 
122 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
                 
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                def respond_to?(symbol, include_private = false)
         
     | 
| 
      
 123 
     | 
    
         
            +
                def respond_to_missing?(symbol, include_private = false)
         
     | 
| 
       95 
124 
     | 
    
         
             
                  default_connection.respond_to?(symbol, include_private) || super
         
     | 
| 
       96 
125 
     | 
    
         
             
                end
         
     | 
| 
       97 
126 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                #  
     | 
| 
       100 
     | 
    
         
            -
                #  
     | 
| 
       101 
     | 
    
         
            -
                 
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
      
 127 
     | 
    
         
            +
                # @overload default_connection
         
     | 
| 
      
 128 
     | 
    
         
            +
                #   Gets the default connection used for simple scripts.
         
     | 
| 
      
 129 
     | 
    
         
            +
                #   @return [Faraday::Connection] a connection configured with
         
     | 
| 
      
 130 
     | 
    
         
            +
                #   the default_adapter.
         
     | 
| 
      
 131 
     | 
    
         
            +
                # @overload default_connection=(connection)
         
     | 
| 
      
 132 
     | 
    
         
            +
                #   @param connection [Faraday::Connection]
         
     | 
| 
      
 133 
     | 
    
         
            +
                #   Sets the default {Faraday::Connection} for simple scripts that
         
     | 
| 
      
 134 
     | 
    
         
            +
                #   access the Faraday constant directly, such as
         
     | 
| 
      
 135 
     | 
    
         
            +
                #   <code>Faraday.get "https://faraday.com"</code>.
         
     | 
| 
      
 136 
     | 
    
         
            +
                def default_connection
         
     | 
| 
      
 137 
     | 
    
         
            +
                  @default_connection ||= Connection.new(default_connection_options)
         
     | 
| 
       103 
138 
     | 
    
         
             
                end
         
     | 
| 
       104 
     | 
    
         
            -
              end
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
              self.ignore_env_proxy = false
         
     | 
| 
       107 
     | 
    
         
            -
              self.root_path = File.expand_path "..", __FILE__
         
     | 
| 
       108 
     | 
    
         
            -
              self.lib_path = File.expand_path "../faraday", __FILE__
         
     | 
| 
       109 
     | 
    
         
            -
              self.default_adapter = :net_http
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
              # Gets the default connection used for simple scripts.
         
     | 
| 
       112 
     | 
    
         
            -
              #
         
     | 
| 
       113 
     | 
    
         
            -
              # Returns a Faraday::Connection, configured with the #default_adapter.
         
     | 
| 
       114 
     | 
    
         
            -
              def self.default_connection
         
     | 
| 
       115 
     | 
    
         
            -
                @default_connection ||= Connection.new(default_connection_options)
         
     | 
| 
       116 
     | 
    
         
            -
              end
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
              # Gets the default connection options used when calling Faraday#new.
         
     | 
| 
       119 
     | 
    
         
            -
              #
         
     | 
| 
       120 
     | 
    
         
            -
              # Returns a Faraday::ConnectionOptions.
         
     | 
| 
       121 
     | 
    
         
            -
              def self.default_connection_options
         
     | 
| 
       122 
     | 
    
         
            -
                @default_connection_options ||= ConnectionOptions.new
         
     | 
| 
       123 
     | 
    
         
            -
              end
         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
              # Public: Sets the default options used when calling Faraday#new.
         
     | 
| 
       126 
     | 
    
         
            -
              def self.default_connection_options=(options)
         
     | 
| 
       127 
     | 
    
         
            -
                @default_connection = nil
         
     | 
| 
       128 
     | 
    
         
            -
                @default_connection_options = ConnectionOptions.from(options)
         
     | 
| 
       129 
     | 
    
         
            -
              end
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
              unless const_defined? :Timer
         
     | 
| 
       132 
     | 
    
         
            -
                require 'timeout'
         
     | 
| 
       133 
     | 
    
         
            -
                Timer = Timeout
         
     | 
| 
       134 
     | 
    
         
            -
              end
         
     | 
| 
       135 
139 
     | 
    
         | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
              # middleware classes.
         
     | 
| 
       138 
     | 
    
         
            -
              module MiddlewareRegistry
         
     | 
| 
       139 
     | 
    
         
            -
                # Public: Register middleware class(es) on the current module.
         
     | 
| 
       140 
     | 
    
         
            -
                #
         
     | 
| 
       141 
     | 
    
         
            -
                # mapping - A Hash mapping Symbol keys to classes. Classes can be expressed
         
     | 
| 
       142 
     | 
    
         
            -
                #           as fully qualified constant, or a Proc that will be lazily
         
     | 
| 
       143 
     | 
    
         
            -
                #           called to return the former.
         
     | 
| 
       144 
     | 
    
         
            -
                #
         
     | 
| 
       145 
     | 
    
         
            -
                # Examples
         
     | 
| 
       146 
     | 
    
         
            -
                #
         
     | 
| 
       147 
     | 
    
         
            -
                #   module Faraday
         
     | 
| 
       148 
     | 
    
         
            -
                #     class Whatever
         
     | 
| 
       149 
     | 
    
         
            -
                #       # Middleware looked up by :foo returns Faraday::Whatever::Foo.
         
     | 
| 
       150 
     | 
    
         
            -
                #       register_middleware :foo => Foo
         
     | 
| 
      
 140 
     | 
    
         
            +
                # Gets the default connection options used when calling {Faraday#new}.
         
     | 
| 
       151 
141 
     | 
    
         
             
                #
         
     | 
| 
       152 
     | 
    
         
            -
                # 
     | 
| 
       153 
     | 
    
         
            -
                 
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
                #       # Middleware looked up by :baz requires 'baz' and returns Faraday::Whatever.const_get(:Baz)
         
     | 
| 
       156 
     | 
    
         
            -
                #       register_middleware :baz => [:Baz, 'baz']
         
     | 
| 
       157 
     | 
    
         
            -
                #     end
         
     | 
| 
       158 
     | 
    
         
            -
                #   end
         
     | 
| 
       159 
     | 
    
         
            -
                #
         
     | 
| 
       160 
     | 
    
         
            -
                # Returns nothing.
         
     | 
| 
       161 
     | 
    
         
            -
                def register_middleware(autoload_path = nil, mapping = nil)
         
     | 
| 
       162 
     | 
    
         
            -
                  if mapping.nil?
         
     | 
| 
       163 
     | 
    
         
            -
                    mapping = autoload_path
         
     | 
| 
       164 
     | 
    
         
            -
                    autoload_path = nil
         
     | 
| 
       165 
     | 
    
         
            -
                  end
         
     | 
| 
       166 
     | 
    
         
            -
                  middleware_mutex do
         
     | 
| 
       167 
     | 
    
         
            -
                    @middleware_autoload_path = autoload_path if autoload_path
         
     | 
| 
       168 
     | 
    
         
            -
                    (@registered_middleware ||= {}).update(mapping)
         
     | 
| 
       169 
     | 
    
         
            -
                  end
         
     | 
| 
      
 142 
     | 
    
         
            +
                # @return [Faraday::ConnectionOptions]
         
     | 
| 
      
 143 
     | 
    
         
            +
                def default_connection_options
         
     | 
| 
      
 144 
     | 
    
         
            +
                  @default_connection_options ||= ConnectionOptions.new
         
     | 
| 
       170 
145 
     | 
    
         
             
                end
         
     | 
| 
       171 
146 
     | 
    
         | 
| 
       172 
     | 
    
         
            -
                #  
     | 
| 
       173 
     | 
    
         
            -
                #
         
     | 
| 
       174 
     | 
    
         
            -
                # key - The Symbol key for the registered middleware.
         
     | 
| 
       175 
     | 
    
         
            -
                #
         
     | 
| 
       176 
     | 
    
         
            -
                # Examples
         
     | 
| 
       177 
     | 
    
         
            -
                #
         
     | 
| 
       178 
     | 
    
         
            -
                #   module Faraday
         
     | 
| 
       179 
     | 
    
         
            -
                #     class Whatever
         
     | 
| 
       180 
     | 
    
         
            -
                #       register_middleware :foo => Foo
         
     | 
| 
       181 
     | 
    
         
            -
                #     end
         
     | 
| 
       182 
     | 
    
         
            -
                #   end
         
     | 
| 
      
 147 
     | 
    
         
            +
                # Sets the default options used when calling {Faraday#new}.
         
     | 
| 
       183 
148 
     | 
    
         
             
                #
         
     | 
| 
       184 
     | 
    
         
            -
                # 
     | 
| 
       185 
     | 
    
         
            -
                 
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
                def lookup_middleware(key)
         
     | 
| 
       189 
     | 
    
         
            -
                  load_middleware(key) ||
         
     | 
| 
       190 
     | 
    
         
            -
                    raise(Faraday::Error.new("#{key.inspect} is not registered on #{self}"))
         
     | 
| 
       191 
     | 
    
         
            -
                end
         
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
                def middleware_mutex(&block)
         
     | 
| 
       194 
     | 
    
         
            -
                  @middleware_mutex ||= begin
         
     | 
| 
       195 
     | 
    
         
            -
                    require 'monitor'
         
     | 
| 
       196 
     | 
    
         
            -
                    Monitor.new
         
     | 
| 
       197 
     | 
    
         
            -
                  end
         
     | 
| 
       198 
     | 
    
         
            -
                  @middleware_mutex.synchronize(&block)
         
     | 
| 
      
 149 
     | 
    
         
            +
                # @param options [Hash, Faraday::ConnectionOptions]
         
     | 
| 
      
 150 
     | 
    
         
            +
                def default_connection_options=(options)
         
     | 
| 
      
 151 
     | 
    
         
            +
                  @default_connection = nil
         
     | 
| 
      
 152 
     | 
    
         
            +
                  @default_connection_options = ConnectionOptions.from(options)
         
     | 
| 
       199 
153 
     | 
    
         
             
                end
         
     | 
| 
       200 
154 
     | 
    
         | 
| 
       201 
     | 
    
         
            -
                 
     | 
| 
       202 
     | 
    
         
            -
                  defined?(@registered_middleware) && @registered_middleware[key]
         
     | 
| 
       203 
     | 
    
         
            -
                end
         
     | 
| 
      
 155 
     | 
    
         
            +
                private
         
     | 
| 
       204 
156 
     | 
    
         | 
| 
       205 
     | 
    
         
            -
                 
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
       207 
     | 
    
         
            -
             
     | 
| 
       208 
     | 
    
         
            -
                   
     | 
| 
       209 
     | 
    
         
            -
                     
     | 
| 
       210 
     | 
    
         
            -
                   
     | 
| 
       211 
     | 
    
         
            -
                     
     | 
| 
       212 
     | 
    
         
            -
                      @registered_middleware[key] = const_get(value)
         
     | 
| 
       213 
     | 
    
         
            -
                    end
         
     | 
| 
       214 
     | 
    
         
            -
                  when Proc
         
     | 
| 
       215 
     | 
    
         
            -
                    middleware_mutex do
         
     | 
| 
       216 
     | 
    
         
            -
                      @registered_middleware[key] = value.call
         
     | 
| 
       217 
     | 
    
         
            -
                    end
         
     | 
| 
       218 
     | 
    
         
            -
                  when Array
         
     | 
| 
       219 
     | 
    
         
            -
                    middleware_mutex do
         
     | 
| 
       220 
     | 
    
         
            -
                      const, path = value
         
     | 
| 
       221 
     | 
    
         
            -
                      if root = @middleware_autoload_path
         
     | 
| 
       222 
     | 
    
         
            -
                        path = "#{root}/#{path}"
         
     | 
| 
       223 
     | 
    
         
            -
                      end
         
     | 
| 
       224 
     | 
    
         
            -
                      require(path)
         
     | 
| 
       225 
     | 
    
         
            -
                      @registered_middleware[key] = const
         
     | 
| 
       226 
     | 
    
         
            -
                    end
         
     | 
| 
       227 
     | 
    
         
            -
                    load_middleware(key)
         
     | 
| 
      
 157 
     | 
    
         
            +
                # Internal: Proxies method calls on the Faraday constant to
         
     | 
| 
      
 158 
     | 
    
         
            +
                # .default_connection.
         
     | 
| 
      
 159 
     | 
    
         
            +
                def method_missing(name, *args, &block)
         
     | 
| 
      
 160 
     | 
    
         
            +
                  if default_connection.respond_to?(name)
         
     | 
| 
      
 161 
     | 
    
         
            +
                    default_connection.send(name, *args, &block)
         
     | 
| 
      
 162 
     | 
    
         
            +
                  else
         
     | 
| 
      
 163 
     | 
    
         
            +
                    super
         
     | 
| 
       228 
164 
     | 
    
         
             
                  end
         
     | 
| 
       229 
165 
     | 
    
         
             
                end
         
     | 
| 
       230 
166 
     | 
    
         
             
              end
         
     | 
| 
       231 
167 
     | 
    
         | 
| 
       232 
     | 
    
         
            -
               
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
       234 
     | 
    
         
            -
             
     | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
       236 
     | 
    
         
            -
                else
         
     | 
| 
       237 
     | 
    
         
            -
                  super
         
     | 
| 
       238 
     | 
    
         
            -
                end
         
     | 
| 
       239 
     | 
    
         
            -
              end
         
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
              require_libs "utils", "options", "connection", "rack_builder", "parameters",
         
     | 
| 
       242 
     | 
    
         
            -
                "middleware", "adapter", "request", "response", "upload_io", "error"
         
     | 
| 
      
 168 
     | 
    
         
            +
              self.ignore_env_proxy = false
         
     | 
| 
      
 169 
     | 
    
         
            +
              self.root_path = File.expand_path __dir__
         
     | 
| 
      
 170 
     | 
    
         
            +
              self.lib_path = File.expand_path 'faraday', __dir__
         
     | 
| 
      
 171 
     | 
    
         
            +
              self.default_adapter = :net_http
         
     | 
| 
       243 
172 
     | 
    
         | 
| 
       244 
     | 
    
         
            -
               
     | 
| 
       245 
     | 
    
         
            -
                require_lib 'autoload'
         
     | 
| 
       246 
     | 
    
         
            -
              end
         
     | 
| 
      
 173 
     | 
    
         
            +
              require_lib 'autoload' unless ENV['FARADAY_NO_AUTOLOAD']
         
     | 
| 
       247 
174 
     | 
    
         
             
            end
         
     |