faraday 1.0.1 → 1.4.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 +104 -0
 - data/LICENSE.md +1 -1
 - data/README.md +3 -5
 - data/examples/client_spec.rb +1 -1
 - data/lib/faraday.rb +53 -41
 - data/lib/faraday/adapter.rb +1 -6
 - data/lib/faraday/adapter/em_http.rb +16 -13
 - data/lib/faraday/adapter/em_synchrony.rb +16 -13
 - data/lib/faraday/autoload.rb +1 -4
 - data/lib/faraday/connection.rb +5 -4
 - data/lib/faraday/encoders/flat_params_encoder.rb +9 -2
 - data/lib/faraday/encoders/nested_params_encoder.rb +7 -2
 - data/lib/faraday/error.rb +20 -0
 - data/lib/faraday/methods.rb +6 -0
 - data/lib/faraday/middleware.rb +14 -4
 - data/lib/faraday/options.rb +4 -8
 - data/lib/faraday/rack_builder.rb +13 -12
 - data/lib/faraday/request.rb +20 -10
 - data/lib/faraday/request/multipart.rb +9 -2
 - data/lib/faraday/request/retry.rb +2 -2
 - data/lib/faraday/response.rb +0 -6
 - data/lib/faraday/response/raise_error.rb +12 -1
 - data/lib/faraday/utils.rb +2 -2
 - data/lib/faraday/utils/headers.rb +2 -2
 - data/lib/faraday/version.rb +5 -0
 - data/spec/faraday/adapter/test_spec.rb +260 -0
 - data/spec/faraday/connection_spec.rb +30 -0
 - data/spec/faraday/error_spec.rb +15 -0
 - data/spec/faraday/middleware_spec.rb +32 -6
 - data/spec/faraday/params_encoders/flat_spec.rb +8 -0
 - data/spec/faraday/params_encoders/nested_spec.rb +8 -0
 - data/spec/faraday/rack_builder_spec.rb +149 -0
 - data/spec/faraday/request/authorization_spec.rb +2 -2
 - data/spec/faraday/request/multipart_spec.rb +41 -13
 - data/spec/faraday/request/retry_spec.rb +1 -1
 - data/spec/faraday/request_spec.rb +16 -5
 - data/spec/faraday/response/raise_error_spec.rb +63 -0
 - data/spec/support/shared_examples/adapter.rb +2 -1
 - data/spec/support/shared_examples/request_method.rb +39 -11
 - metadata +64 -9
 - data/lib/faraday/adapter/excon.rb +0 -124
 - data/lib/faraday/adapter/net_http.rb +0 -219
 - data/lib/faraday/adapter/net_http_persistent.rb +0 -91
 - data/spec/faraday/adapter/net_http_persistent_spec.rb +0 -57
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9232bd1a6a03e460d5959725591c2aeae3094f3e29a48dadcf9531ee878d61b2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 261fa4b48f2eb5633abc5352f30965693e8b0b283c7204645ad0ea562d82d3ad
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d707ade012eacb6eb017365b18778ad8553cec5f27a8571331ab5b3bc388605f0b8692de98c1ab36c60528dfbcd2cfe0e12b0bdec343240721dd08f16d4fd376
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 86fef1e9db15dcb666b9255d1f5aea529aa2c2a51fe0cdd7ca011f00870299c2200d6b200d801516269281f2b524248670b40bb0ca57d130358a2383e7e50f01
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,109 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Faraday Changelog
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## [v1.3.0](https://github.com/lostisland/faraday/releases/tag/v1.3.0) (2020-12-31)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ### Highlights
         
     | 
| 
      
 6 
     | 
    
         
            +
            Faraday v1.3.0 is the first release to officially support Ruby 3.0 in the CI pipeline 🎉 🍾! 
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            This is also the first release with a previously "included" adapter (Net::HTTP) being isolated into a [separate gem](https://github.com/lostisland/faraday-net_http) 🎊!
         
     | 
| 
      
 9 
     | 
    
         
            +
            The new adapter is added to Faraday as a dependency for now, so that means full backwards-compatibility, but just to be safe be careful when upgrading!
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            This is a huge step towards are Faraday v2.0 objective of pushing adapters and middleware into separate gems.
         
     | 
| 
      
 12 
     | 
    
         
            +
            Many thanks to the Faraday Team, @JanDintel and everyone who attended the [ROSS Conf remote event](https://www.rossconf.io/event/remote/)
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            ### Features
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            * Improves consistency with Faraday::Error and Faraday::RaiseError (#1229, @qsona, @iMacTia)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ### Fixes
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            * Don't assign to global ::Timer (#1227, @bpo)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            ### Documentation
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            * CHANGELOG: add releases after 1.0 (#1225, @olleolleolle)
         
     | 
| 
      
 25 
     | 
    
         
            +
            * Improves retry middleware documentation. (#1228, @iMacTia)
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ### Misc
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            * Move out Net::HTTP adapter (#1222, @JanDintel, @iMacTia)
         
     | 
| 
      
 30 
     | 
    
         
            +
            * Adds Ruby 3.0 to CI Matrix (#1226, @iMacTia)
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            ## [v1.2.0](https://github.com/lostisland/faraday/releases/tag/v1.2.0) (2020-12-23)
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            ### Features
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            * Introduces `on_request` and `on_complete` methods in `Faraday::Middleware`. (#1194, @iMacTia)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            ### Fixes
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            * Require 'date' to avoid retry exception (#1206, @rustygeldmacher)
         
     | 
| 
      
 42 
     | 
    
         
            +
            * Fix rdebug recursion issue (#1205, @native-api)
         
     | 
| 
      
 43 
     | 
    
         
            +
            * Update call to `em_http_ssl_patch` (#1202, @kylekeesling)
         
     | 
| 
      
 44 
     | 
    
         
            +
            * `EmHttp` adapter: drop superfluous loaded? check (#1213, @olleolleolle)
         
     | 
| 
      
 45 
     | 
    
         
            +
            * Avoid 1 use of keyword hackery (#1211, @grosser)
         
     | 
| 
      
 46 
     | 
    
         
            +
            * Fix #1219 `Net::HTTP` still uses env proxy (#1221, @iMacTia)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            ### Documentation
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            * Add comment in gemspec to explain exposure of `examples` and `spec` folders. (#1192, @iMacTia)
         
     | 
| 
      
 51 
     | 
    
         
            +
            * Adapters, how to create them (#1193, @olleolleolle)
         
     | 
| 
      
 52 
     | 
    
         
            +
            * Update documentation on using the logger (#1196, @tijmenb)
         
     | 
| 
      
 53 
     | 
    
         
            +
            * Adjust the retry documentation and spec to align with implementation (#1198, @nbeyer)
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            ### Misc
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            * Test against ruby head (#1208, @grosser)
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            ## [v1.1.0](https://github.com/lostisland/faraday/releases/tag/v1.1.0) (2020-10-17)
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            ### Features
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            * Makes parameters sorting configurable (#1162 @wishdev)
         
     | 
| 
      
 64 
     | 
    
         
            +
            * Introduces `flat_encode` option for multipart adapter. (#1163 @iMacTia)
         
     | 
| 
      
 65 
     | 
    
         
            +
            * Include request info in exceptions raised by RaiseError Middleware (#1181 @SandroDamilano)
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            ### Fixes
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            * Avoid `last arg as keyword param` warning when building user middleware on Ruby 2.7 (#1153 @dgholz)
         
     | 
| 
      
 70 
     | 
    
         
            +
            * Limits net-http-persistent version to < 4.0 (#1156 @iMacTia)
         
     | 
| 
      
 71 
     | 
    
         
            +
            * Update `typhoeus` to new stable version (`1.4`) (#1159 @AlexWayfer)
         
     | 
| 
      
 72 
     | 
    
         
            +
            * Properly fix test failure with Rack 2.1+. (#1171 @voxik)
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            ### Documentation
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            * Improves documentation on how to contribute to the site by using Docker. (#1175 @iMacTia)
         
     | 
| 
      
 77 
     | 
    
         
            +
            * Remove retry_change_requests from documentation (#1185 @stim371)
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            ### Misc
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            * Link from GitHub Actions badge to CI workflow (#1141 @olleolleolle)
         
     | 
| 
      
 82 
     | 
    
         
            +
            * Return tests of `Test` adapter (#1147 @AlexWayfer)
         
     | 
| 
      
 83 
     | 
    
         
            +
            * Add 1.0 release to wording in CONTRIBUTING (#1155 @olleolleolle)
         
     | 
| 
      
 84 
     | 
    
         
            +
            * Fix linting bumping Rubocop to 0.90.0 (#1182 @iMacTia)
         
     | 
| 
      
 85 
     | 
    
         
            +
            * Drop `git ls-files` in gemspec (#1183 @utkarsh2102)
         
     | 
| 
      
 86 
     | 
    
         
            +
            * Upgrade CI to ruby/setup-ruby (#1187 @gogainda)
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            ## [v1.0.1](https://github.com/lostisland/faraday/releases/tag/v1.0.1) (2020-03-29)
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            ### Fixes
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            * Use Net::HTTP#start(&block) to ensure closed TCP connections (#1117)
         
     | 
| 
      
 93 
     | 
    
         
            +
            * Fully qualify constants to be checked (#1122)
         
     | 
| 
      
 94 
     | 
    
         
            +
            * Allows `parse` method to be private/protected in response middleware (#1123)
         
     | 
| 
      
 95 
     | 
    
         
            +
            * Encode Spaces in Query Strings as '%20' Instead of '+' (#1125)
         
     | 
| 
      
 96 
     | 
    
         
            +
            * Limits rack to v2.0.x (#1127)
         
     | 
| 
      
 97 
     | 
    
         
            +
            * Adapter Registry reads also use mutex (#1136) 
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            ### Documentation
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            * Retry middleware documentation fix (#1109)
         
     | 
| 
      
 102 
     | 
    
         
            +
            * Docs(retry): precise usage of retry-after (#1111)
         
     | 
| 
      
 103 
     | 
    
         
            +
            * README: Link the logo to the website (#1112)
         
     | 
| 
      
 104 
     | 
    
         
            +
            * Website: add search bar (#1116)
         
     | 
| 
      
 105 
     | 
    
         
            +
            * Fix request/response mix-up in docs text (#1132)
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
       3 
107 
     | 
    
         
             
            ## v1.0
         
     | 
| 
       4 
108 
     | 
    
         | 
| 
       5 
109 
     | 
    
         
             
            Features:
         
     | 
    
        data/LICENSE.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,9 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # [][website]
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            [](https://rubygems.org/gems/faraday)
         
     | 
| 
       4 
     | 
    
         
            -
            
         
     | 
| 
       5 
     | 
    
         
            -
            [](https://codeclimate.com/github/lostisland/faraday/test_coverage)
         
     | 
| 
       6 
     | 
    
         
            -
            [](https://codeclimate.com/github/lostisland/faraday/maintainability)
         
     | 
| 
      
 4 
     | 
    
         
            +
            [](https://github.com/lostisland/faraday/actions?query=workflow%3ACI)
         
     | 
| 
       7 
5 
     | 
    
         
             
            [](https://gitter.im/lostisland/faraday?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
7 
     | 
    
         | 
| 
         @@ -43,12 +41,12 @@ Open the issues page and check for the `help wanted` label! 
     | 
|
| 
       43 
41 
     | 
    
         
             
            But before you start coding, please read our [Contributing Guide][contributing]
         
     | 
| 
       44 
42 
     | 
    
         | 
| 
       45 
43 
     | 
    
         
             
            ## Copyright
         
     | 
| 
       46 
     | 
    
         
            -
            © 2009 -  
     | 
| 
      
 44 
     | 
    
         
            +
            © 2009 - 2020, the [Faraday Team][faraday_team]. Website and branding design by [Elena Lo Piccolo](https://elelopic.design).
         
     | 
| 
       47 
45 
     | 
    
         | 
| 
       48 
46 
     | 
    
         
             
            [website]:      https://lostisland.github.io/faraday
         
     | 
| 
       49 
47 
     | 
    
         
             
            [faraday_team]: https://lostisland.github.io/faraday/team
         
     | 
| 
       50 
48 
     | 
    
         
             
            [contributing]: https://github.com/lostisland/faraday/blob/master/.github/CONTRIBUTING.md
         
     | 
| 
       51 
     | 
    
         
            -
            [apidoc]:        
     | 
| 
      
 49 
     | 
    
         
            +
            [apidoc]:       https://www.rubydoc.info/github/lostisland/faraday
         
     | 
| 
       52 
50 
     | 
    
         
             
            [actions]:      https://github.com/lostisland/faraday/actions
         
     | 
| 
       53 
51 
     | 
    
         
             
            [jruby]:        http://jruby.org/
         
     | 
| 
       54 
52 
     | 
    
         
             
            [rubinius]:     http://rubini.us/
         
     | 
    
        data/examples/client_spec.rb
    CHANGED
    
    
    
        data/lib/faraday.rb
    CHANGED
    
    | 
         @@ -1,11 +1,36 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require 'cgi'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'date'
         
     | 
| 
       4 
5 
     | 
    
         
             
            require 'set'
         
     | 
| 
       5 
6 
     | 
    
         
             
            require 'forwardable'
         
     | 
| 
       6 
7 
     | 
    
         
             
            require 'faraday/middleware_registry'
         
     | 
| 
       7 
8 
     | 
    
         
             
            require 'faraday/dependency_loader'
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
      
 10 
     | 
    
         
            +
            unless defined?(::Faraday::Timer)
         
     | 
| 
      
 11 
     | 
    
         
            +
              require 'timeout'
         
     | 
| 
      
 12 
     | 
    
         
            +
              ::Faraday::Timer = Timeout
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 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 
     | 
    
         
            +
            require 'faraday/net_http'
         
     | 
| 
      
 31 
     | 
    
         
            +
            require 'faraday/net_http_persistent'
         
     | 
| 
      
 32 
     | 
    
         
            +
            require 'faraday/excon'
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       9 
34 
     | 
    
         
             
            # This is the main namespace for Faraday.
         
     | 
| 
       10 
35 
     | 
    
         
             
            #
         
     | 
| 
       11 
36 
     | 
    
         
             
            # It provides methods to create {Connection} objects, and HTTP-related
         
     | 
| 
         @@ -19,10 +44,6 @@ require 'faraday/dependency_loader' 
     | 
|
| 
       19 
44 
     | 
    
         
             
            #   conn.get '/'
         
     | 
| 
       20 
45 
     | 
    
         
             
            #
         
     | 
| 
       21 
46 
     | 
    
         
             
            module Faraday
         
     | 
| 
       22 
     | 
    
         
            -
              VERSION = '1.0.1'
         
     | 
| 
       23 
     | 
    
         
            -
              METHODS_WITH_QUERY = %w[get head delete trace].freeze
         
     | 
| 
       24 
     | 
    
         
            -
              METHODS_WITH_BODY = %w[post put patch].freeze
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
47 
     | 
    
         
             
              class << self
         
     | 
| 
       27 
48 
     | 
    
         
             
                # The root path that Faraday is being loaded from.
         
     | 
| 
       28 
49 
     | 
    
         
             
                #
         
     | 
| 
         @@ -107,6 +128,34 @@ module Faraday 
     | 
|
| 
       107 
128 
     | 
    
         
             
                  default_connection.respond_to?(symbol, include_private) || super
         
     | 
| 
       108 
129 
     | 
    
         
             
                end
         
     | 
| 
       109 
130 
     | 
    
         | 
| 
      
 131 
     | 
    
         
            +
                # @overload default_connection
         
     | 
| 
      
 132 
     | 
    
         
            +
                #   Gets the default connection used for simple scripts.
         
     | 
| 
      
 133 
     | 
    
         
            +
                #   @return [Faraday::Connection] a connection configured with
         
     | 
| 
      
 134 
     | 
    
         
            +
                #   the default_adapter.
         
     | 
| 
      
 135 
     | 
    
         
            +
                # @overload default_connection=(connection)
         
     | 
| 
      
 136 
     | 
    
         
            +
                #   @param connection [Faraday::Connection]
         
     | 
| 
      
 137 
     | 
    
         
            +
                #   Sets the default {Faraday::Connection} for simple scripts that
         
     | 
| 
      
 138 
     | 
    
         
            +
                #   access the Faraday constant directly, such as
         
     | 
| 
      
 139 
     | 
    
         
            +
                #   <code>Faraday.get "https://faraday.com"</code>.
         
     | 
| 
      
 140 
     | 
    
         
            +
                def default_connection
         
     | 
| 
      
 141 
     | 
    
         
            +
                  @default_connection ||= Connection.new(default_connection_options)
         
     | 
| 
      
 142 
     | 
    
         
            +
                end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
                # Gets the default connection options used when calling {Faraday#new}.
         
     | 
| 
      
 145 
     | 
    
         
            +
                #
         
     | 
| 
      
 146 
     | 
    
         
            +
                # @return [Faraday::ConnectionOptions]
         
     | 
| 
      
 147 
     | 
    
         
            +
                def default_connection_options
         
     | 
| 
      
 148 
     | 
    
         
            +
                  @default_connection_options ||= ConnectionOptions.new
         
     | 
| 
      
 149 
     | 
    
         
            +
                end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                # Sets the default options used when calling {Faraday#new}.
         
     | 
| 
      
 152 
     | 
    
         
            +
                #
         
     | 
| 
      
 153 
     | 
    
         
            +
                # @param options [Hash, Faraday::ConnectionOptions]
         
     | 
| 
      
 154 
     | 
    
         
            +
                def default_connection_options=(options)
         
     | 
| 
      
 155 
     | 
    
         
            +
                  @default_connection = nil
         
     | 
| 
      
 156 
     | 
    
         
            +
                  @default_connection_options = ConnectionOptions.from(options)
         
     | 
| 
      
 157 
     | 
    
         
            +
                end
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
       110 
159 
     | 
    
         
             
                private
         
     | 
| 
       111 
160 
     | 
    
         | 
| 
       112 
161 
     | 
    
         
             
                # Internal: Proxies method calls on the Faraday constant to
         
     | 
| 
         @@ -125,42 +174,5 @@ module Faraday 
     | 
|
| 
       125 
174 
     | 
    
         
             
              self.lib_path = File.expand_path 'faraday', __dir__
         
     | 
| 
       126 
175 
     | 
    
         
             
              self.default_adapter = :net_http
         
     | 
| 
       127 
176 
     | 
    
         | 
| 
       128 
     | 
    
         
            -
              # @overload default_connection
         
     | 
| 
       129 
     | 
    
         
            -
              #   Gets the default connection used for simple scripts.
         
     | 
| 
       130 
     | 
    
         
            -
              #   @return [Faraday::Connection] a connection configured with
         
     | 
| 
       131 
     | 
    
         
            -
              #   the default_adapter.
         
     | 
| 
       132 
     | 
    
         
            -
              # @overload default_connection=(connection)
         
     | 
| 
       133 
     | 
    
         
            -
              #   @param connection [Faraday::Connection]
         
     | 
| 
       134 
     | 
    
         
            -
              #   Sets the default {Faraday::Connection} for simple scripts that
         
     | 
| 
       135 
     | 
    
         
            -
              #   access the Faraday constant directly, such as
         
     | 
| 
       136 
     | 
    
         
            -
              #   <code>Faraday.get "https://faraday.com"</code>.
         
     | 
| 
       137 
     | 
    
         
            -
              def self.default_connection
         
     | 
| 
       138 
     | 
    
         
            -
                @default_connection ||= Connection.new(default_connection_options)
         
     | 
| 
       139 
     | 
    
         
            -
              end
         
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
              # Gets the default connection options used when calling {Faraday#new}.
         
     | 
| 
       142 
     | 
    
         
            -
              #
         
     | 
| 
       143 
     | 
    
         
            -
              # @return [Faraday::ConnectionOptions]
         
     | 
| 
       144 
     | 
    
         
            -
              def self.default_connection_options
         
     | 
| 
       145 
     | 
    
         
            -
                @default_connection_options ||= ConnectionOptions.new
         
     | 
| 
       146 
     | 
    
         
            -
              end
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
              # Sets the default options used when calling {Faraday#new}.
         
     | 
| 
       149 
     | 
    
         
            -
              #
         
     | 
| 
       150 
     | 
    
         
            -
              # @param options [Hash, Faraday::ConnectionOptions]
         
     | 
| 
       151 
     | 
    
         
            -
              def self.default_connection_options=(options)
         
     | 
| 
       152 
     | 
    
         
            -
                @default_connection = nil
         
     | 
| 
       153 
     | 
    
         
            -
                @default_connection_options = ConnectionOptions.from(options)
         
     | 
| 
       154 
     | 
    
         
            -
              end
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
              unless defined?(::Faraday::Timer)
         
     | 
| 
       157 
     | 
    
         
            -
                require 'timeout'
         
     | 
| 
       158 
     | 
    
         
            -
                Timer = Timeout
         
     | 
| 
       159 
     | 
    
         
            -
              end
         
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
              require_libs 'utils', 'options', 'connection', 'rack_builder', 'parameters',
         
     | 
| 
       162 
     | 
    
         
            -
                           'middleware', 'adapter', 'request', 'response', 'error',
         
     | 
| 
       163 
     | 
    
         
            -
                           'file_part', 'param_part'
         
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
177 
     | 
    
         
             
              require_lib 'autoload' unless ENV['FARADAY_NO_AUTOLOAD']
         
     | 
| 
       166 
178 
     | 
    
         
             
            end
         
     | 
    
        data/lib/faraday/adapter.rb
    CHANGED
    
    | 
         @@ -11,22 +11,17 @@ module Faraday 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                register_middleware File.expand_path('adapter', __dir__),
         
     | 
| 
       13 
13 
     | 
    
         
             
                                    test: [:Test, 'test'],
         
     | 
| 
       14 
     | 
    
         
            -
                                    net_http: [:NetHttp, 'net_http'],
         
     | 
| 
       15 
     | 
    
         
            -
                                    net_http_persistent: [
         
     | 
| 
       16 
     | 
    
         
            -
                                      :NetHttpPersistent,
         
     | 
| 
       17 
     | 
    
         
            -
                                      'net_http_persistent'
         
     | 
| 
       18 
     | 
    
         
            -
                                    ],
         
     | 
| 
       19 
14 
     | 
    
         
             
                                    typhoeus: [:Typhoeus, 'typhoeus'],
         
     | 
| 
       20 
15 
     | 
    
         
             
                                    patron: [:Patron, 'patron'],
         
     | 
| 
       21 
16 
     | 
    
         
             
                                    em_synchrony: [:EMSynchrony, 'em_synchrony'],
         
     | 
| 
       22 
17 
     | 
    
         
             
                                    em_http: [:EMHttp, 'em_http'],
         
     | 
| 
       23 
     | 
    
         
            -
                                    excon: [:Excon, 'excon'],
         
     | 
| 
       24 
18 
     | 
    
         
             
                                    rack: [:Rack, 'rack'],
         
     | 
| 
       25 
19 
     | 
    
         
             
                                    httpclient: [:HTTPClient, 'httpclient']
         
     | 
| 
       26 
20 
     | 
    
         | 
| 
       27 
21 
     | 
    
         
             
                # This module marks an Adapter as supporting parallel requests.
         
     | 
| 
       28 
22 
     | 
    
         
             
                module Parallelism
         
     | 
| 
       29 
23 
     | 
    
         
             
                  attr_writer :supports_parallel
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       30 
25 
     | 
    
         
             
                  def supports_parallel?
         
     | 
| 
       31 
26 
     | 
    
         
             
                    @supports_parallel
         
     | 
| 
       32 
27 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -90,7 +90,21 @@ module Faraday 
     | 
|
| 
       90 
90 
     | 
    
         | 
| 
       91 
91 
     | 
    
         
             
                  include Options
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
                  dependency  
     | 
| 
      
 93 
     | 
    
         
            +
                  dependency do
         
     | 
| 
      
 94 
     | 
    
         
            +
                    require 'em-http'
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 97 
     | 
    
         
            +
                      require 'openssl'
         
     | 
| 
      
 98 
     | 
    
         
            +
                    rescue LoadError
         
     | 
| 
      
 99 
     | 
    
         
            +
                      warn 'Warning: no such file to load -- openssl. ' \
         
     | 
| 
      
 100 
     | 
    
         
            +
                        'Make sure it is installed if you want HTTPS support'
         
     | 
| 
      
 101 
     | 
    
         
            +
                    else
         
     | 
| 
      
 102 
     | 
    
         
            +
                      require 'em-http/version'
         
     | 
| 
      
 103 
     | 
    
         
            +
                      if EventMachine::HttpRequest::VERSION < '1.1.6'
         
     | 
| 
      
 104 
     | 
    
         
            +
                        require 'faraday/adapter/em_http_ssl_patch'
         
     | 
| 
      
 105 
     | 
    
         
            +
                      end
         
     | 
| 
      
 106 
     | 
    
         
            +
                    end
         
     | 
| 
      
 107 
     | 
    
         
            +
                  end
         
     | 
| 
       94 
108 
     | 
    
         | 
| 
       95 
109 
     | 
    
         
             
                  self.supports_parallel = true
         
     | 
| 
       96 
110 
     | 
    
         | 
| 
         @@ -231,7 +245,7 @@ module Faraday 
     | 
|
| 
       231 
245 
     | 
    
         | 
| 
       232 
246 
     | 
    
         
             
                    def add(&block)
         
     | 
| 
       233 
247 
     | 
    
         
             
                      if running?
         
     | 
| 
       234 
     | 
    
         
            -
                        perform_request 
     | 
| 
      
 248 
     | 
    
         
            +
                        perform_request(&block)
         
     | 
| 
       235 
249 
     | 
    
         
             
                      else
         
     | 
| 
       236 
250 
     | 
    
         
             
                        @registered_procs << block
         
     | 
| 
       237 
251 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -273,14 +287,3 @@ module Faraday 
     | 
|
| 
       273 
287 
     | 
    
         
             
                end
         
     | 
| 
       274 
288 
     | 
    
         
             
              end
         
     | 
| 
       275 
289 
     | 
    
         
             
            end
         
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
            if Faraday::Adapter::EMHttp.loaded?
         
     | 
| 
       278 
     | 
    
         
            -
              begin
         
     | 
| 
       279 
     | 
    
         
            -
                require 'openssl'
         
     | 
| 
       280 
     | 
    
         
            -
              rescue LoadError
         
     | 
| 
       281 
     | 
    
         
            -
                warn 'Warning: no such file to load -- openssl. ' \
         
     | 
| 
       282 
     | 
    
         
            -
                  'Make sure it is installed if you want HTTPS support'
         
     | 
| 
       283 
     | 
    
         
            -
              else
         
     | 
| 
       284 
     | 
    
         
            -
                require 'faraday/adapter/em_http_ssl_patch'
         
     | 
| 
       285 
     | 
    
         
            -
              end
         
     | 
| 
       286 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -12,6 +12,22 @@ module Faraday 
     | 
|
| 
       12 
12 
     | 
    
         
             
                    require 'em-synchrony/em-http'
         
     | 
| 
       13 
13 
     | 
    
         
             
                    require 'em-synchrony/em-multi'
         
     | 
| 
       14 
14 
     | 
    
         
             
                    require 'fiber'
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    require 'faraday/adapter/em_synchrony/parallel_manager'
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    if Faraday::Adapter::EMSynchrony.loaded?
         
     | 
| 
      
 19 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 20 
     | 
    
         
            +
                        require 'openssl'
         
     | 
| 
      
 21 
     | 
    
         
            +
                      rescue LoadError
         
     | 
| 
      
 22 
     | 
    
         
            +
                        warn 'Warning: no such file to load -- openssl. ' \
         
     | 
| 
      
 23 
     | 
    
         
            +
                          'Make sure it is installed if you want HTTPS support'
         
     | 
| 
      
 24 
     | 
    
         
            +
                      else
         
     | 
| 
      
 25 
     | 
    
         
            +
                        require 'em-http/version'
         
     | 
| 
      
 26 
     | 
    
         
            +
                        if EventMachine::HttpRequest::VERSION < '1.1.6'
         
     | 
| 
      
 27 
     | 
    
         
            +
                          require 'faraday/adapter/em_http_ssl_patch'
         
     | 
| 
      
 28 
     | 
    
         
            +
                        end
         
     | 
| 
      
 29 
     | 
    
         
            +
                      end
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
       15 
31 
     | 
    
         
             
                  end
         
     | 
| 
       16 
32 
     | 
    
         | 
| 
       17 
33 
     | 
    
         
             
                  self.supports_parallel = true
         
     | 
| 
         @@ -135,16 +151,3 @@ module Faraday 
     | 
|
| 
       135 
151 
     | 
    
         
             
                end
         
     | 
| 
       136 
152 
     | 
    
         
             
              end
         
     | 
| 
       137 
153 
     | 
    
         
             
            end
         
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
            require 'faraday/adapter/em_synchrony/parallel_manager'
         
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
            if Faraday::Adapter::EMSynchrony.loaded?
         
     | 
| 
       142 
     | 
    
         
            -
              begin
         
     | 
| 
       143 
     | 
    
         
            -
                require 'openssl'
         
     | 
| 
       144 
     | 
    
         
            -
              rescue LoadError
         
     | 
| 
       145 
     | 
    
         
            -
                warn 'Warning: no such file to load -- openssl. ' \
         
     | 
| 
       146 
     | 
    
         
            -
                  'Make sure it is installed if you want HTTPS support'
         
     | 
| 
       147 
     | 
    
         
            -
              else
         
     | 
| 
       148 
     | 
    
         
            -
                require 'faraday/adapter/em_http_ssl_patch'
         
     | 
| 
       149 
     | 
    
         
            -
              end
         
     | 
| 
       150 
     | 
    
         
            -
            end
         
     | 
    
        data/lib/faraday/autoload.rb
    CHANGED
    
    | 
         @@ -23,7 +23,7 @@ module Faraday 
     | 
|
| 
       23 
23 
     | 
    
         
             
                #
         
     | 
| 
       24 
24 
     | 
    
         
             
                # @return [void]
         
     | 
| 
       25 
25 
     | 
    
         
             
                def autoload_all(prefix, options)
         
     | 
| 
       26 
     | 
    
         
            -
                  if prefix  
     | 
| 
      
 26 
     | 
    
         
            +
                  if prefix.match? %r{^faraday(/|$)}i
         
     | 
| 
       27 
27 
     | 
    
         
             
                    prefix = File.join(Faraday.root_path, prefix)
         
     | 
| 
       28 
28 
     | 
    
         
             
                  end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
         @@ -58,13 +58,10 @@ module Faraday 
     | 
|
| 
       58 
58 
     | 
    
         
             
              class Adapter
         
     | 
| 
       59 
59 
     | 
    
         
             
                extend AutoloadHelper
         
     | 
| 
       60 
60 
     | 
    
         
             
                autoload_all 'faraday/adapter',
         
     | 
| 
       61 
     | 
    
         
            -
                             NetHttp: 'net_http',
         
     | 
| 
       62 
     | 
    
         
            -
                             NetHttpPersistent: 'net_http_persistent',
         
     | 
| 
       63 
61 
     | 
    
         
             
                             EMSynchrony: 'em_synchrony',
         
     | 
| 
       64 
62 
     | 
    
         
             
                             EMHttp: 'em_http',
         
     | 
| 
       65 
63 
     | 
    
         
             
                             Typhoeus: 'typhoeus',
         
     | 
| 
       66 
64 
     | 
    
         
             
                             Patron: 'patron',
         
     | 
| 
       67 
     | 
    
         
            -
                             Excon: 'excon',
         
     | 
| 
       68 
65 
     | 
    
         
             
                             Test: 'test',
         
     | 
| 
       69 
66 
     | 
    
         
             
                             Rack: 'rack',
         
     | 
| 
       70 
67 
     | 
    
         
             
                             HTTPClient: 'httpclient'
         
     | 
    
        data/lib/faraday/connection.rb
    CHANGED
    
    | 
         @@ -429,7 +429,7 @@ module Faraday 
     | 
|
| 
       429 
429 
     | 
    
         
             
                # @return [String] the new path prefix
         
     | 
| 
       430 
430 
     | 
    
         
             
                def path_prefix=(value)
         
     | 
| 
       431 
431 
     | 
    
         
             
                  url_prefix.path = if value
         
     | 
| 
       432 
     | 
    
         
            -
                                      value =  
     | 
| 
      
 432 
     | 
    
         
            +
                                      value = "/#{value}" unless value[0, 1] == '/'
         
     | 
| 
       433 
433 
     | 
    
         
             
                                      value
         
     | 
| 
       434 
434 
     | 
    
         
             
                                    end
         
     | 
| 
       435 
435 
     | 
    
         
             
                end
         
     | 
| 
         @@ -520,8 +520,9 @@ module Faraday 
     | 
|
| 
       520 
520 
     | 
    
         
             
                  base = url_prefix
         
     | 
| 
       521 
521 
     | 
    
         
             
                  if url && base.path && base.path !~ %r{/$}
         
     | 
| 
       522 
522 
     | 
    
         
             
                    base = base.dup
         
     | 
| 
       523 
     | 
    
         
            -
                    base.path = base.path 
     | 
| 
      
 523 
     | 
    
         
            +
                    base.path = "#{base.path}/" # ensure trailing slash
         
     | 
| 
       524 
524 
     | 
    
         
             
                  end
         
     | 
| 
      
 525 
     | 
    
         
            +
                  url = url && URI.parse(url.to_s).opaque ? url.to_s.gsub(':', '%3A') : url
         
     | 
| 
       525 
526 
     | 
    
         
             
                  uri = url ? base + url : base
         
     | 
| 
       526 
527 
     | 
    
         
             
                  if params
         
     | 
| 
       527 
528 
     | 
    
         
             
                    uri.query = params.to_query(params_encoder || options.params_encoder)
         
     | 
| 
         @@ -576,7 +577,7 @@ module Faraday 
     | 
|
| 
       576 
577 
     | 
    
         
             
                    case url
         
     | 
| 
       577 
578 
     | 
    
         
             
                    when String
         
     | 
| 
       578 
579 
     | 
    
         
             
                      uri = Utils.URI(url)
         
     | 
| 
       579 
     | 
    
         
            -
                      uri = URI.parse("#{uri.scheme}://#{uri. 
     | 
| 
      
 580 
     | 
    
         
            +
                      uri = URI.parse("#{uri.scheme}://#{uri.host}").find_proxy
         
     | 
| 
       580 
581 
     | 
    
         
             
                    when URI
         
     | 
| 
       581 
582 
     | 
    
         
             
                      uri = url.find_proxy
         
     | 
| 
       582 
583 
     | 
    
         
             
                    when nil
         
     | 
| 
         @@ -593,7 +594,7 @@ module Faraday 
     | 
|
| 
       593 
594 
     | 
    
         
             
                  uri = ENV['http_proxy']
         
     | 
| 
       594 
595 
     | 
    
         
             
                  return unless uri && !uri.empty?
         
     | 
| 
       595 
596 
     | 
    
         | 
| 
       596 
     | 
    
         
            -
                  uri =  
     | 
| 
      
 597 
     | 
    
         
            +
                  uri = "http://#{uri}" unless uri.match?(/^http/i)
         
     | 
| 
       597 
598 
     | 
    
         
             
                  uri
         
     | 
| 
       598 
599 
     | 
    
         
             
                end
         
     | 
| 
       599 
600 
     | 
    
         |