faraday 0.9.1 → 0.17.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 +5 -5
- data/LICENSE.md +1 -1
- data/README.md +192 -28
- data/lib/faraday/adapter/em_http.rb +8 -2
- data/lib/faraday/adapter/em_http_ssl_patch.rb +1 -1
- data/lib/faraday/adapter/em_synchrony.rb +16 -2
- data/lib/faraday/adapter/excon.rb +10 -8
- data/lib/faraday/adapter/httpclient.rb +27 -5
- data/lib/faraday/adapter/net_http.rb +34 -12
- data/lib/faraday/adapter/net_http_persistent.rb +35 -15
- data/lib/faraday/adapter/patron.rb +39 -16
- data/lib/faraday/adapter/test.rb +79 -28
- data/lib/faraday/adapter/typhoeus.rb +4 -115
- data/lib/faraday/adapter.rb +10 -1
- data/lib/faraday/autoload.rb +1 -1
- data/lib/faraday/connection.rb +72 -20
- data/lib/faraday/error.rb +18 -5
- data/lib/faraday/options.rb +42 -19
- data/lib/faraday/parameters.rb +56 -39
- data/lib/faraday/rack_builder.rb +27 -2
- data/lib/faraday/request/authorization.rb +1 -2
- data/lib/faraday/request/multipart.rb +7 -2
- data/lib/faraday/request/retry.rb +82 -18
- data/lib/faraday/request.rb +22 -0
- data/lib/faraday/response/logger.rb +29 -8
- data/lib/faraday/response.rb +6 -2
- data/lib/faraday/utils.rb +32 -3
- data/lib/faraday.rb +14 -34
- metadata +7 -94
- data/.document +0 -6
- data/CHANGELOG.md +0 -20
- data/CONTRIBUTING.md +0 -36
- data/Gemfile +0 -25
- data/Rakefile +0 -71
- data/faraday.gemspec +0 -34
- data/script/cached-bundle +0 -46
- data/script/console +0 -7
- data/script/generate_certs +0 -42
- data/script/package +0 -7
- data/script/proxy-server +0 -42
- data/script/release +0 -17
- data/script/s3-put +0 -71
- data/script/server +0 -36
- data/script/test +0 -172
- data/test/adapters/default_test.rb +0 -14
- data/test/adapters/em_http_test.rb +0 -20
- data/test/adapters/em_synchrony_test.rb +0 -20
- data/test/adapters/excon_test.rb +0 -20
- data/test/adapters/httpclient_test.rb +0 -21
- data/test/adapters/integration.rb +0 -254
- data/test/adapters/logger_test.rb +0 -82
- data/test/adapters/net_http_persistent_test.rb +0 -20
- data/test/adapters/net_http_test.rb +0 -14
- data/test/adapters/patron_test.rb +0 -20
- data/test/adapters/rack_test.rb +0 -31
- data/test/adapters/test_middleware_test.rb +0 -114
- data/test/adapters/typhoeus_test.rb +0 -28
- data/test/authentication_middleware_test.rb +0 -65
- data/test/composite_read_io_test.rb +0 -111
- data/test/connection_test.rb +0 -522
- data/test/env_test.rb +0 -218
- data/test/helper.rb +0 -81
- data/test/live_server.rb +0 -67
- data/test/middleware/instrumentation_test.rb +0 -88
- data/test/middleware/retry_test.rb +0 -177
- data/test/middleware_stack_test.rb +0 -173
- data/test/multibyte.txt +0 -1
- data/test/options_test.rb +0 -252
- data/test/parameters_test.rb +0 -64
- data/test/request_middleware_test.rb +0 -142
- data/test/response_middleware_test.rb +0 -72
- data/test/strawberry.rb +0 -2
- data/test/utils_test.rb +0 -58
    
        data/lib/faraday/response.rb
    CHANGED
    
    | @@ -37,6 +37,10 @@ module Faraday | |
| 37 37 | 
             
                  finished? ? env.status : nil
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            +
                def reason_phrase
         | 
| 41 | 
            +
                  finished? ? env.reason_phrase : nil
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 40 44 | 
             
                def headers
         | 
| 41 45 | 
             
                  finished? ? env.response_headers : {}
         | 
| 42 46 | 
             
                end
         | 
| @@ -61,8 +65,8 @@ module Faraday | |
| 61 65 |  | 
| 62 66 | 
             
                def finish(env)
         | 
| 63 67 | 
             
                  raise "response already finished" if finished?
         | 
| 64 | 
            -
                  @ | 
| 65 | 
            -
                  @ | 
| 68 | 
            +
                  @env = env.is_a?(Env) ? env : Env.from(env)
         | 
| 69 | 
            +
                  @on_complete_callbacks.each { |callback| callback.call(@env) }
         | 
| 66 70 | 
             
                  return self
         | 
| 67 71 | 
             
                end
         | 
| 68 72 |  | 
    
        data/lib/faraday/utils.rb
    CHANGED
    
    | @@ -1,5 +1,4 @@ | |
| 1 1 | 
             
            require 'thread'
         | 
| 2 | 
            -
            Faraday.require_libs 'parameters'
         | 
| 3 2 |  | 
| 4 3 | 
             
            module Faraday
         | 
| 5 4 | 
             
              module Utils
         | 
| @@ -11,12 +10,28 @@ module Faraday | |
| 11 10 | 
             
                    new(value)
         | 
| 12 11 | 
             
                  end
         | 
| 13 12 |  | 
| 13 | 
            +
                  def self.allocate
         | 
| 14 | 
            +
                    new_self = super
         | 
| 15 | 
            +
                    new_self.initialize_names
         | 
| 16 | 
            +
                    new_self
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 14 19 | 
             
                  def initialize(hash = nil)
         | 
| 15 20 | 
             
                    super()
         | 
| 16 21 | 
             
                    @names = {}
         | 
| 17 22 | 
             
                    self.update(hash || {})
         | 
| 18 23 | 
             
                  end
         | 
| 19 24 |  | 
| 25 | 
            +
                  def initialize_names
         | 
| 26 | 
            +
                    @names = {}
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  # on dup/clone, we need to duplicate @names hash
         | 
| 30 | 
            +
                  def initialize_copy(other)
         | 
| 31 | 
            +
                    super
         | 
| 32 | 
            +
                    @names = other.names.dup
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 20 35 | 
             
                  # need to synchronize concurrent writes to the shared KeyMap
         | 
| 21 36 | 
             
                  keymap_mutex = Mutex.new
         | 
| 22 37 |  | 
| @@ -81,6 +96,7 @@ module Faraday | |
| 81 96 |  | 
| 82 97 | 
             
                  def replace(other)
         | 
| 83 98 | 
             
                    clear
         | 
| 99 | 
            +
                    @names.clear
         | 
| 84 100 | 
             
                    self.update other
         | 
| 85 101 | 
             
                    self
         | 
| 86 102 | 
             
                  end
         | 
| @@ -89,9 +105,16 @@ module Faraday | |
| 89 105 |  | 
| 90 106 | 
             
                  def parse(header_string)
         | 
| 91 107 | 
             
                    return unless header_string && !header_string.empty?
         | 
| 92 | 
            -
             | 
| 108 | 
            +
             | 
| 109 | 
            +
                    headers = header_string.split(/\r\n/)
         | 
| 110 | 
            +
             | 
| 111 | 
            +
                    # Find the last set of response headers.
         | 
| 112 | 
            +
                    start_index = headers.rindex { |x| x.match(/^HTTP\//) } || 0
         | 
| 113 | 
            +
                    last_response = headers.slice(start_index, headers.size)
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                    last_response.
         | 
| 93 116 | 
             
                      tap  { |a| a.shift if a.first.index('HTTP/') == 0 }. # drop the HTTP status line
         | 
| 94 | 
            -
                      map  { |h| h.split(/:\s | 
| 117 | 
            +
                      map  { |h| h.split(/:\s*/, 2) }.reject { |p| p[0].nil? }. # split key and value, ignore blank lines
         | 
| 95 118 | 
             
                      each { |key, value|
         | 
| 96 119 | 
             
                        # join multiple values with a comma
         | 
| 97 120 | 
             
                        if self[key]
         | 
| @@ -101,6 +124,12 @@ module Faraday | |
| 101 124 | 
             
                        end
         | 
| 102 125 | 
             
                      }
         | 
| 103 126 | 
             
                  end
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                  protected
         | 
| 129 | 
            +
             | 
| 130 | 
            +
                  def names
         | 
| 131 | 
            +
                    @names
         | 
| 132 | 
            +
                  end
         | 
| 104 133 | 
             
                end
         | 
| 105 134 |  | 
| 106 135 | 
             
                # hash with stringified keys
         | 
    
        data/lib/faraday.rb
    CHANGED
    
    | @@ -14,7 +14,7 @@ require 'forwardable' | |
| 14 14 | 
             
            #   conn.get '/'
         | 
| 15 15 | 
             
            #
         | 
| 16 16 | 
             
            module Faraday
         | 
| 17 | 
            -
              VERSION = "0. | 
| 17 | 
            +
              VERSION = "0.17.0"
         | 
| 18 18 |  | 
| 19 19 | 
             
              class << self
         | 
| 20 20 | 
             
                # Public: Gets or sets the root path that Faraday is being loaded from.
         | 
| @@ -34,8 +34,8 @@ module Faraday | |
| 34 34 | 
             
                #     Faraday.get "https://faraday.com"
         | 
| 35 35 | 
             
                attr_writer :default_connection
         | 
| 36 36 |  | 
| 37 | 
            -
                # Public:  | 
| 38 | 
            -
                 | 
| 37 | 
            +
                # Public: Tells faraday to ignore the environment proxy (http_proxy).
         | 
| 38 | 
            +
                attr_accessor :ignore_env_proxy
         | 
| 39 39 |  | 
| 40 40 | 
             
                # Public: Initializes a new Faraday::Connection.
         | 
| 41 41 | 
             
                #
         | 
| @@ -66,7 +66,7 @@ module Faraday | |
| 66 66 | 
             
                # Returns a Faraday::Connection.
         | 
| 67 67 | 
             
                def new(url = nil, options = nil)
         | 
| 68 68 | 
             
                  block = block_given? ? Proc.new : nil
         | 
| 69 | 
            -
                  options = options ? default_connection_options.merge(options) : default_connection_options | 
| 69 | 
            +
                  options = options ? default_connection_options.merge(options) : default_connection_options
         | 
| 70 70 | 
             
                  Faraday::Connection.new(url, options, &block)
         | 
| 71 71 | 
             
                end
         | 
| 72 72 |  | 
| @@ -92,6 +92,10 @@ module Faraday | |
| 92 92 |  | 
| 93 93 | 
             
                alias require_lib require_libs
         | 
| 94 94 |  | 
| 95 | 
            +
                def respond_to?(symbol, include_private = false)
         | 
| 96 | 
            +
                  default_connection.respond_to?(symbol, include_private) || super
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 95 99 | 
             
              private
         | 
| 96 100 | 
             
                # Internal: Proxies method calls on the Faraday constant to
         | 
| 97 101 | 
             
                # #default_connection.
         | 
| @@ -100,6 +104,7 @@ module Faraday | |
| 100 104 | 
             
                end
         | 
| 101 105 | 
             
              end
         | 
| 102 106 |  | 
| 107 | 
            +
              self.ignore_env_proxy = false
         | 
| 103 108 | 
             
              self.root_path = File.expand_path "..", __FILE__
         | 
| 104 109 | 
             
              self.lib_path = File.expand_path "../faraday", __FILE__
         | 
| 105 110 | 
             
              self.default_adapter = :net_http
         | 
| @@ -108,7 +113,7 @@ module Faraday | |
| 108 113 | 
             
              #
         | 
| 109 114 | 
             
              # Returns a Faraday::Connection, configured with the #default_adapter.
         | 
| 110 115 | 
             
              def self.default_connection
         | 
| 111 | 
            -
                @default_connection ||= Connection.new
         | 
| 116 | 
            +
                @default_connection ||= Connection.new(default_connection_options)
         | 
| 112 117 | 
             
              end
         | 
| 113 118 |  | 
| 114 119 | 
             
              # Gets the default connection options used when calling Faraday#new.
         | 
| @@ -118,13 +123,10 @@ module Faraday | |
| 118 123 | 
             
                @default_connection_options ||= ConnectionOptions.new
         | 
| 119 124 | 
             
              end
         | 
| 120 125 |  | 
| 121 | 
            -
               | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 125 | 
            -
                rescue LoadError
         | 
| 126 | 
            -
                  warn "Faraday: you may want to install system_timer for reliable timeouts"
         | 
| 127 | 
            -
                end
         | 
| 126 | 
            +
              # Public: Sets the default options used when calling Faraday#new.
         | 
| 127 | 
            +
              def self.default_connection_options=(options)
         | 
| 128 | 
            +
                @default_connection = nil
         | 
| 129 | 
            +
                @default_connection_options = ConnectionOptions.from(options)
         | 
| 128 130 | 
             
              end
         | 
| 129 131 |  | 
| 130 132 | 
             
              unless const_defined? :Timer
         | 
| @@ -244,25 +246,3 @@ module Faraday | |
| 244 246 | 
             
                require_lib 'autoload'
         | 
| 245 247 | 
             
              end
         | 
| 246 248 | 
             
            end
         | 
| 247 | 
            -
             | 
| 248 | 
            -
            # not pulling in active-support JUST for this method.  And I love this method.
         | 
| 249 | 
            -
            class Object
         | 
| 250 | 
            -
              # The primary purpose of this method is to "tap into" a method chain,
         | 
| 251 | 
            -
              # in order to perform operations on intermediate results within the chain.
         | 
| 252 | 
            -
              #
         | 
| 253 | 
            -
              # Examples
         | 
| 254 | 
            -
              #
         | 
| 255 | 
            -
              #   (1..10).tap { |x| puts "original: #{x.inspect}" }.to_a.
         | 
| 256 | 
            -
              #     tap    { |x| puts "array: #{x.inspect}" }.
         | 
| 257 | 
            -
              #     select { |x| x%2 == 0 }.
         | 
| 258 | 
            -
              #     tap    { |x| puts "evens: #{x.inspect}" }.
         | 
| 259 | 
            -
              #     map    { |x| x*x }.
         | 
| 260 | 
            -
              #     tap    { |x| puts "squares: #{x.inspect}" }
         | 
| 261 | 
            -
              #
         | 
| 262 | 
            -
              # Yields self.
         | 
| 263 | 
            -
              # Returns self.
         | 
| 264 | 
            -
              def tap
         | 
| 265 | 
            -
                yield(self)
         | 
| 266 | 
            -
                self
         | 
| 267 | 
            -
              end unless Object.respond_to?(:tap)
         | 
| 268 | 
            -
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: faraday
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.17.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Rick Olson
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2019-10-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: multipart-post
         | 
| @@ -30,34 +30,14 @@ dependencies: | |
| 30 30 | 
             
                - - "<"
         | 
| 31 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 32 | 
             
                    version: '3'
         | 
| 33 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            -
              name: bundler
         | 
| 35 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            -
                requirements:
         | 
| 37 | 
            -
                - - "~>"
         | 
| 38 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            -
                    version: '1.0'
         | 
| 40 | 
            -
              type: :development
         | 
| 41 | 
            -
              prerelease: false
         | 
| 42 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 | 
            -
                requirements:
         | 
| 44 | 
            -
                - - "~>"
         | 
| 45 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            -
                    version: '1.0'
         | 
| 47 33 | 
             
            description: 
         | 
| 48 34 | 
             
            email: technoweenie@gmail.com
         | 
| 49 35 | 
             
            executables: []
         | 
| 50 36 | 
             
            extensions: []
         | 
| 51 37 | 
             
            extra_rdoc_files: []
         | 
| 52 38 | 
             
            files:
         | 
| 53 | 
            -
            - ".document"
         | 
| 54 | 
            -
            - CHANGELOG.md
         | 
| 55 | 
            -
            - CONTRIBUTING.md
         | 
| 56 | 
            -
            - Gemfile
         | 
| 57 39 | 
             
            - LICENSE.md
         | 
| 58 40 | 
             
            - README.md
         | 
| 59 | 
            -
            - Rakefile
         | 
| 60 | 
            -
            - faraday.gemspec
         | 
| 61 41 | 
             
            - lib/faraday.rb
         | 
| 62 42 | 
             
            - lib/faraday/adapter.rb
         | 
| 63 43 | 
             
            - lib/faraday/adapter/em_http.rb
         | 
| @@ -92,44 +72,6 @@ files: | |
| 92 72 | 
             
            - lib/faraday/response/raise_error.rb
         | 
| 93 73 | 
             
            - lib/faraday/upload_io.rb
         | 
| 94 74 | 
             
            - lib/faraday/utils.rb
         | 
| 95 | 
            -
            - script/cached-bundle
         | 
| 96 | 
            -
            - script/console
         | 
| 97 | 
            -
            - script/generate_certs
         | 
| 98 | 
            -
            - script/package
         | 
| 99 | 
            -
            - script/proxy-server
         | 
| 100 | 
            -
            - script/release
         | 
| 101 | 
            -
            - script/s3-put
         | 
| 102 | 
            -
            - script/server
         | 
| 103 | 
            -
            - script/test
         | 
| 104 | 
            -
            - test/adapters/default_test.rb
         | 
| 105 | 
            -
            - test/adapters/em_http_test.rb
         | 
| 106 | 
            -
            - test/adapters/em_synchrony_test.rb
         | 
| 107 | 
            -
            - test/adapters/excon_test.rb
         | 
| 108 | 
            -
            - test/adapters/httpclient_test.rb
         | 
| 109 | 
            -
            - test/adapters/integration.rb
         | 
| 110 | 
            -
            - test/adapters/logger_test.rb
         | 
| 111 | 
            -
            - test/adapters/net_http_persistent_test.rb
         | 
| 112 | 
            -
            - test/adapters/net_http_test.rb
         | 
| 113 | 
            -
            - test/adapters/patron_test.rb
         | 
| 114 | 
            -
            - test/adapters/rack_test.rb
         | 
| 115 | 
            -
            - test/adapters/test_middleware_test.rb
         | 
| 116 | 
            -
            - test/adapters/typhoeus_test.rb
         | 
| 117 | 
            -
            - test/authentication_middleware_test.rb
         | 
| 118 | 
            -
            - test/composite_read_io_test.rb
         | 
| 119 | 
            -
            - test/connection_test.rb
         | 
| 120 | 
            -
            - test/env_test.rb
         | 
| 121 | 
            -
            - test/helper.rb
         | 
| 122 | 
            -
            - test/live_server.rb
         | 
| 123 | 
            -
            - test/middleware/instrumentation_test.rb
         | 
| 124 | 
            -
            - test/middleware/retry_test.rb
         | 
| 125 | 
            -
            - test/middleware_stack_test.rb
         | 
| 126 | 
            -
            - test/multibyte.txt
         | 
| 127 | 
            -
            - test/options_test.rb
         | 
| 128 | 
            -
            - test/parameters_test.rb
         | 
| 129 | 
            -
            - test/request_middleware_test.rb
         | 
| 130 | 
            -
            - test/response_middleware_test.rb
         | 
| 131 | 
            -
            - test/strawberry.rb
         | 
| 132 | 
            -
            - test/utils_test.rb
         | 
| 133 75 | 
             
            homepage: https://github.com/lostisland/faraday
         | 
| 134 76 | 
             
            licenses:
         | 
| 135 77 | 
             
            - MIT
         | 
| @@ -142,44 +84,15 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 142 84 | 
             
              requirements:
         | 
| 143 85 | 
             
              - - ">="
         | 
| 144 86 | 
             
                - !ruby/object:Gem::Version
         | 
| 145 | 
            -
                  version: ' | 
| 87 | 
            +
                  version: '1.9'
         | 
| 146 88 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 147 89 | 
             
              requirements:
         | 
| 148 90 | 
             
              - - ">="
         | 
| 149 91 | 
             
                - !ruby/object:Gem::Version
         | 
| 150 | 
            -
                  version:  | 
| 92 | 
            +
                  version: '0'
         | 
| 151 93 | 
             
            requirements: []
         | 
| 152 | 
            -
             | 
| 153 | 
            -
            rubygems_version: 2.2.2
         | 
| 94 | 
            +
            rubygems_version: 3.0.3
         | 
| 154 95 | 
             
            signing_key: 
         | 
| 155 | 
            -
            specification_version:  | 
| 96 | 
            +
            specification_version: 4
         | 
| 156 97 | 
             
            summary: HTTP/REST API client library.
         | 
| 157 | 
            -
            test_files:
         | 
| 158 | 
            -
            - test/adapters/default_test.rb
         | 
| 159 | 
            -
            - test/adapters/em_http_test.rb
         | 
| 160 | 
            -
            - test/adapters/em_synchrony_test.rb
         | 
| 161 | 
            -
            - test/adapters/excon_test.rb
         | 
| 162 | 
            -
            - test/adapters/httpclient_test.rb
         | 
| 163 | 
            -
            - test/adapters/integration.rb
         | 
| 164 | 
            -
            - test/adapters/logger_test.rb
         | 
| 165 | 
            -
            - test/adapters/net_http_persistent_test.rb
         | 
| 166 | 
            -
            - test/adapters/net_http_test.rb
         | 
| 167 | 
            -
            - test/adapters/patron_test.rb
         | 
| 168 | 
            -
            - test/adapters/rack_test.rb
         | 
| 169 | 
            -
            - test/adapters/test_middleware_test.rb
         | 
| 170 | 
            -
            - test/adapters/typhoeus_test.rb
         | 
| 171 | 
            -
            - test/authentication_middleware_test.rb
         | 
| 172 | 
            -
            - test/composite_read_io_test.rb
         | 
| 173 | 
            -
            - test/connection_test.rb
         | 
| 174 | 
            -
            - test/env_test.rb
         | 
| 175 | 
            -
            - test/helper.rb
         | 
| 176 | 
            -
            - test/live_server.rb
         | 
| 177 | 
            -
            - test/middleware/instrumentation_test.rb
         | 
| 178 | 
            -
            - test/middleware/retry_test.rb
         | 
| 179 | 
            -
            - test/middleware_stack_test.rb
         | 
| 180 | 
            -
            - test/options_test.rb
         | 
| 181 | 
            -
            - test/parameters_test.rb
         | 
| 182 | 
            -
            - test/request_middleware_test.rb
         | 
| 183 | 
            -
            - test/response_middleware_test.rb
         | 
| 184 | 
            -
            - test/strawberry.rb
         | 
| 185 | 
            -
            - test/utils_test.rb
         | 
| 98 | 
            +
            test_files: []
         | 
    
        data/.document
    DELETED
    
    
    
        data/CHANGELOG.md
    DELETED
    
    | @@ -1,20 +0,0 @@ | |
| 1 | 
            -
            # Faraday Changelog
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            ## v0.9.1
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            * Refactor Net:HTTP adapter so that with_net_http_connection can be overridden to allow pooled connections. (@Ben-M)
         | 
| 6 | 
            -
            * Add configurable methods that bypass `retry_if` in the Retry request middleware.  (@mike-bourgeous)
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            ## v0.9.0
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            * Add HTTPClient adapter (@hakanensari)
         | 
| 11 | 
            -
            * Improve Retry handler (@mislav)
         | 
| 12 | 
            -
            * Remove autoloading by default (@technoweenie)
         | 
| 13 | 
            -
            * Improve internal docs (@technoweenie, @mislav)
         | 
| 14 | 
            -
            * Respect user/password in http proxy string (@mislav)
         | 
| 15 | 
            -
            * Adapter options are structs.  Reinforces consistent options across adapters
         | 
| 16 | 
            -
              (@technoweenie)
         | 
| 17 | 
            -
            * Stop stripping trailing / off base URLs in a Faraday::Connection. (@technoweenie)
         | 
| 18 | 
            -
            * Add a configurable URI parser. (@technoweenie)
         | 
| 19 | 
            -
            * Remove need to manually autoload when using the authorization header helpers on `Faraday::Connection`. (@technoweenie)
         | 
| 20 | 
            -
            * `Faraday::Adapter::Test` respects the `Faraday::RequestOptions#params_encoder` option. (@technoweenie)
         | 
    
        data/CONTRIBUTING.md
    DELETED
    
    | @@ -1,36 +0,0 @@ | |
| 1 | 
            -
            ## Contributing
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            You can run the test suite against a live server by running `script/test`. It
         | 
| 4 | 
            -
            automatically starts a test server in background. Only tests in
         | 
| 5 | 
            -
            `test/adapters/*_test.rb` require a server, though.
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            ``` sh
         | 
| 8 | 
            -
            # run the whole suite
         | 
| 9 | 
            -
            $ script/test
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            # run only specific files
         | 
| 12 | 
            -
            $ script/test excon typhoeus
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            # run tests using SSL
         | 
| 15 | 
            -
            $ SSL=yes script/test
         | 
| 16 | 
            -
            ```
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            We will accept middleware that:
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            1. is useful to a broader audience, but can be implemented relatively
         | 
| 21 | 
            -
               simple; and
         | 
| 22 | 
            -
            2. which isn't already present in [faraday_middleware][] project.
         | 
| 23 | 
            -
             | 
| 24 | 
            -
            We will accept adapters that:
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            1. support SSL & streaming;
         | 
| 27 | 
            -
            1. are proven and may have better performance than existing ones; or
         | 
| 28 | 
            -
            2. if they have features not present in included adapters.
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            We are pushing towards a 1.0 release, when we will have to follow [Semantic
         | 
| 31 | 
            -
            Versioning][semver].  If your patch includes changes to break compatibility,
         | 
| 32 | 
            -
            note that so we can add it to the [Changelog][].
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            [semver]:    http://semver.org/
         | 
| 35 | 
            -
            [changelog]: https://github.com/lostisland/faraday/wiki/Changelog
         | 
| 36 | 
            -
            [faraday_middleware]: https://github.com/lostisland/faraday_middleware/wiki
         | 
    
        data/Gemfile
    DELETED
    
    | @@ -1,25 +0,0 @@ | |
| 1 | 
            -
            source 'https://rubygems.org'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            gem 'ffi-ncurses', '~> 0.3', :platforms => :jruby
         | 
| 4 | 
            -
            gem 'jruby-openssl', '~> 0.8.8', :platforms => :jruby
         | 
| 5 | 
            -
            gem 'rake'
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            group :test do
         | 
| 8 | 
            -
              gem 'coveralls', :require => false
         | 
| 9 | 
            -
              gem 'em-http-request', '>= 1.1', :require => 'em-http'
         | 
| 10 | 
            -
              gem 'em-synchrony', '>= 1.0.3', :require => ['em-synchrony', 'em-synchrony/em-http']
         | 
| 11 | 
            -
              gem 'excon', '>= 0.27.4'
         | 
| 12 | 
            -
              gem 'httpclient', '>= 2.2'
         | 
| 13 | 
            -
              gem 'leftright', '>= 0.9', :require => false
         | 
| 14 | 
            -
              gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
         | 
| 15 | 
            -
              gem 'minitest', '>= 5.0.5'
         | 
| 16 | 
            -
              gem 'net-http-persistent', '>= 2.9.4'
         | 
| 17 | 
            -
              gem 'patron', '>= 0.4.2', :platforms => :ruby
         | 
| 18 | 
            -
              gem 'rack-test', '>= 0.6', :require => 'rack/test'
         | 
| 19 | 
            -
              gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
         | 
| 20 | 
            -
              gem 'simplecov'
         | 
| 21 | 
            -
              gem 'sinatra', '~> 1.3'
         | 
| 22 | 
            -
              gem 'typhoeus', '~> 0.3.3', :platforms => :ruby
         | 
| 23 | 
            -
            end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            gemspec
         | 
    
        data/Rakefile
    DELETED
    
    | @@ -1,71 +0,0 @@ | |
| 1 | 
            -
            require 'date'
         | 
| 2 | 
            -
            require 'fileutils'
         | 
| 3 | 
            -
            require 'openssl'
         | 
| 4 | 
            -
            require 'rake/testtask'
         | 
| 5 | 
            -
            require 'bundler'
         | 
| 6 | 
            -
            Bundler::GemHelper.install_tasks
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            task :default => :test
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            ## helper functions
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            def name
         | 
| 13 | 
            -
              @name ||= Dir['*.gemspec'].first.split('.').first
         | 
| 14 | 
            -
            end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            def version
         | 
| 17 | 
            -
              line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
         | 
| 18 | 
            -
              line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
         | 
| 19 | 
            -
            end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
            def gemspec_file
         | 
| 22 | 
            -
              "#{name}.gemspec"
         | 
| 23 | 
            -
            end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            def gem_file
         | 
| 26 | 
            -
              "#{name}-#{version}.gem"
         | 
| 27 | 
            -
            end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            def replace_header(head, header_name)
         | 
| 30 | 
            -
              head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
         | 
| 31 | 
            -
            end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            # Adapted from WEBrick::Utils. Skips cert extensions so it
         | 
| 34 | 
            -
            # can be used as a CA bundle
         | 
| 35 | 
            -
            def create_self_signed_cert(bits, cn, comment)
         | 
| 36 | 
            -
              rsa = OpenSSL::PKey::RSA.new(bits)
         | 
| 37 | 
            -
              cert = OpenSSL::X509::Certificate.new
         | 
| 38 | 
            -
              cert.version = 2
         | 
| 39 | 
            -
              cert.serial = 1
         | 
| 40 | 
            -
              name = OpenSSL::X509::Name.new(cn)
         | 
| 41 | 
            -
              cert.subject = name
         | 
| 42 | 
            -
              cert.issuer = name
         | 
| 43 | 
            -
              cert.not_before = Time.now
         | 
| 44 | 
            -
              cert.not_after = Time.now + (365*24*60*60)
         | 
| 45 | 
            -
              cert.public_key = rsa.public_key
         | 
| 46 | 
            -
              cert.sign(rsa, OpenSSL::Digest::SHA1.new)
         | 
| 47 | 
            -
              return [cert, rsa]
         | 
| 48 | 
            -
            end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
            ## standard tasks
         | 
| 51 | 
            -
             | 
| 52 | 
            -
            desc "Run all tests"
         | 
| 53 | 
            -
            task :test do
         | 
| 54 | 
            -
              exec 'script/test'
         | 
| 55 | 
            -
            end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
            desc "Generate certificates for SSL tests"
         | 
| 58 | 
            -
            task :'test:generate_certs' do
         | 
| 59 | 
            -
              cert, key = create_self_signed_cert(1024, [['CN', 'localhost']], 'Faraday Test CA')
         | 
| 60 | 
            -
              FileUtils.mkdir_p 'tmp'
         | 
| 61 | 
            -
              File.open('tmp/faraday-cert.key', 'w') {|f| f.puts(key) }
         | 
| 62 | 
            -
              File.open('tmp/faraday-cert.crt', 'w') {|f| f.puts(cert.to_s) }
         | 
| 63 | 
            -
            end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
            file 'tmp/faraday-cert.key' => :'test:generate_certs'
         | 
| 66 | 
            -
            file 'tmp/faraday-cert.crt' => :'test:generate_certs'
         | 
| 67 | 
            -
             | 
| 68 | 
            -
            desc "Open an irb session preloaded with this library"
         | 
| 69 | 
            -
            task :console do
         | 
| 70 | 
            -
              sh "irb -rubygems -r ./lib/#{name}.rb"
         | 
| 71 | 
            -
            end
         | 
    
        data/faraday.gemspec
    DELETED
    
    | @@ -1,34 +0,0 @@ | |
| 1 | 
            -
            lib = "faraday"
         | 
| 2 | 
            -
            lib_file = File.expand_path("../lib/#{lib}.rb", __FILE__)
         | 
| 3 | 
            -
            File.read(lib_file) =~ /\bVERSION\s*=\s*["'](.+?)["']/
         | 
| 4 | 
            -
            version = $1
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            Gem::Specification.new do |spec|
         | 
| 7 | 
            -
              spec.specification_version = 2 if spec.respond_to? :specification_version=
         | 
| 8 | 
            -
              spec.required_rubygems_version = '>= 1.3.5'
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              spec.name    = lib
         | 
| 11 | 
            -
              spec.version = version
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              spec.summary = "HTTP/REST API client library."
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              spec.authors  = ["Rick Olson"]
         | 
| 16 | 
            -
              spec.email    = 'technoweenie@gmail.com'
         | 
| 17 | 
            -
              spec.homepage = 'https://github.com/lostisland/faraday'
         | 
| 18 | 
            -
              spec.licenses = ['MIT']
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              spec.add_dependency 'multipart-post', '>= 1.2', '< 3'
         | 
| 21 | 
            -
              spec.add_development_dependency 'bundler', '~> 1.0'
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              spec.files = %w(.document CHANGELOG.md CONTRIBUTING.md Gemfile LICENSE.md README.md Rakefile)
         | 
| 24 | 
            -
              spec.files << "#{lib}.gemspec"
         | 
| 25 | 
            -
              spec.files += Dir.glob("lib/**/*.rb")
         | 
| 26 | 
            -
              spec.files += Dir.glob("test/**/*.{rb,txt}")
         | 
| 27 | 
            -
              spec.files += Dir.glob("script/*")
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              dev_null    = File.exist?('/dev/null') ? '/dev/null' : 'NUL'
         | 
| 30 | 
            -
              git_files   = `git ls-files -z 2>#{dev_null}`
         | 
| 31 | 
            -
              spec.files &= git_files.split("\0") if $?.success?
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              spec.test_files = Dir.glob("test/**/*.rb")
         | 
| 34 | 
            -
            end
         | 
    
        data/script/cached-bundle
    DELETED
    
    | @@ -1,46 +0,0 @@ | |
| 1 | 
            -
            #!/usr/bin/env bash
         | 
| 2 | 
            -
            # Usage: cached-bundle install --deployment
         | 
| 3 | 
            -
            #
         | 
| 4 | 
            -
            # After running `bundle`, caches the `./bundle` directory to S3.
         | 
| 5 | 
            -
            # On the next run, restores the cached directory before running `bundle`.
         | 
| 6 | 
            -
            # When `Gemfile` changes, the cache gets rebuilt.
         | 
| 7 | 
            -
            #
         | 
| 8 | 
            -
            # Requirements:
         | 
| 9 | 
            -
            # - Gemfile
         | 
| 10 | 
            -
            # - TRAVIS_REPO_SLUG
         | 
| 11 | 
            -
            # - TRAVIS_RUBY_VERSION
         | 
| 12 | 
            -
            # - AMAZON_S3_BUCKET
         | 
| 13 | 
            -
            # - script/s3-put
         | 
| 14 | 
            -
            # - bundle
         | 
| 15 | 
            -
            # - curl
         | 
| 16 | 
            -
            #
         | 
| 17 | 
            -
            # Author: Mislav Marohnić
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            set -e
         | 
| 20 | 
            -
             | 
| 21 | 
            -
            compute_md5() {
         | 
| 22 | 
            -
              local output="$(openssl md5)"
         | 
| 23 | 
            -
              echo "${output##* }"
         | 
| 24 | 
            -
            }
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            download() {
         | 
| 27 | 
            -
              curl --tcp-nodelay -qsfL "$1" -o "$2"
         | 
| 28 | 
            -
            }
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            bundle_path="bundle"
         | 
| 31 | 
            -
            gemfile_hash="$(compute_md5 <"${BUNDLE_GEMFILE:-Gemfile}")"
         | 
| 32 | 
            -
            cache_name="${TRAVIS_RUBY_VERSION}-${gemfile_hash}.tgz"
         | 
| 33 | 
            -
            fetch_url="http://${AMAZON_S3_BUCKET}.s3.amazonaws.com/${TRAVIS_REPO_SLUG}/${cache_name}"
         | 
| 34 | 
            -
             | 
| 35 | 
            -
            if download "$fetch_url" "$cache_name"; then
         | 
| 36 | 
            -
              echo "Reusing cached bundle ${cache_name}"
         | 
| 37 | 
            -
              tar xzf "$cache_name"
         | 
| 38 | 
            -
            fi
         | 
| 39 | 
            -
             | 
| 40 | 
            -
            bundle "$@"
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            if [ ! -f "$cache_name" ] && [ -n "$AMAZON_SECRET_ACCESS_KEY" ]; then
         | 
| 43 | 
            -
              echo "Caching \`${bundle_path}' to S3"
         | 
| 44 | 
            -
              tar czf "$cache_name" "$bundle_path"
         | 
| 45 | 
            -
              script/s3-put "$cache_name" "${AMAZON_S3_BUCKET}:${TRAVIS_REPO_SLUG}/${cache_name}"
         | 
| 46 | 
            -
            fi
         | 
    
        data/script/console
    DELETED
    
    
    
        data/script/generate_certs
    DELETED
    
    | @@ -1,42 +0,0 @@ | |
| 1 | 
            -
            #!/usr/bin/env ruby
         | 
| 2 | 
            -
            # Usage: generate_certs
         | 
| 3 | 
            -
            # Generate test certs for testing Faraday with SSL
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            require 'openssl'
         | 
| 6 | 
            -
            require 'fileutils'
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            $shell = ARGV.include? '-s'
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            # Adapted from WEBrick::Utils. Skips cert extensions so it
         | 
| 11 | 
            -
            # can be used as a CA bundle
         | 
| 12 | 
            -
            def create_self_signed_cert(bits, cn, comment)
         | 
| 13 | 
            -
              rsa = OpenSSL::PKey::RSA.new(bits)
         | 
| 14 | 
            -
              cert = OpenSSL::X509::Certificate.new
         | 
| 15 | 
            -
              cert.version = 2
         | 
| 16 | 
            -
              cert.serial = 1
         | 
| 17 | 
            -
              name = OpenSSL::X509::Name.new(cn)
         | 
| 18 | 
            -
              cert.subject = name
         | 
| 19 | 
            -
              cert.issuer = name
         | 
| 20 | 
            -
              cert.not_before = Time.now
         | 
| 21 | 
            -
              cert.not_after = Time.now + (365*24*60*60)
         | 
| 22 | 
            -
              cert.public_key = rsa.public_key
         | 
| 23 | 
            -
              cert.sign(rsa, OpenSSL::Digest::SHA1.new)
         | 
| 24 | 
            -
              return [cert, rsa]
         | 
| 25 | 
            -
            end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            def write(file, contents, env_var)
         | 
| 28 | 
            -
              FileUtils.mkdir_p(File.dirname(file))
         | 
| 29 | 
            -
              File.open(file, 'w') {|f| f.puts(contents) }
         | 
| 30 | 
            -
              puts %(export #{env_var}="#{file}") if $shell
         | 
| 31 | 
            -
            end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
            # One cert / CA for ease of testing when ignoring verification
         | 
| 35 | 
            -
            cert, key = create_self_signed_cert(1024, [['CN', 'localhost']], 'Faraday Test CA')
         | 
| 36 | 
            -
            write 'tmp/faraday-cert.key', key,  'SSL_KEY'
         | 
| 37 | 
            -
            write 'tmp/faraday-cert.crt', cert, 'SSL_FILE'
         | 
| 38 | 
            -
             | 
| 39 | 
            -
            # And a second CA to prove that verification can fail
         | 
| 40 | 
            -
            cert, key = create_self_signed_cert(1024, [['CN', 'real-ca.com']], 'A different CA')
         | 
| 41 | 
            -
            write 'tmp/faraday-different-ca-cert.key', key,  'SSL_KEY_ALT'
         | 
| 42 | 
            -
            write 'tmp/faraday-different-ca-cert.crt', cert, 'SSL_FILE_ALT'
         | 
    
        data/script/package
    DELETED
    
    
    
        data/script/proxy-server
    DELETED
    
    | @@ -1,42 +0,0 @@ | |
| 1 | 
            -
            #!/usr/bin/env ruby
         | 
| 2 | 
            -
            # Usage: script/proxy-server [-p PORT] [-u USER:PASSWORD]
         | 
| 3 | 
            -
            require 'webrick'
         | 
| 4 | 
            -
            require 'webrick/httpproxy'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            port = 4001
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            if found = ARGV.index('-p')
         | 
| 9 | 
            -
              port = ARGV[found + 1].to_i
         | 
| 10 | 
            -
            end
         | 
| 11 | 
            -
            if found = ARGV.index('-u')
         | 
| 12 | 
            -
              username, password = ARGV[found + 1].split(':', 2)
         | 
| 13 | 
            -
            end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            match_credentials = lambda { |credentials|
         | 
| 16 | 
            -
              got_username, got_password = credentials.to_s.unpack("m*")[0].split(":", 2)
         | 
| 17 | 
            -
              got_username == username && got_password == password
         | 
| 18 | 
            -
            }
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            log_io = $stdout
         | 
| 21 | 
            -
            log_io.sync = true
         | 
| 22 | 
            -
             | 
| 23 | 
            -
            webrick_opts = {
         | 
| 24 | 
            -
              :Port => port, :Logger => WEBrick::Log::new(log_io),
         | 
| 25 | 
            -
              :AccessLog => [[log_io, "[%{X-Faraday-Adapter}i] %m  %U  ->  %s %b"]],
         | 
| 26 | 
            -
              :ProxyAuthProc => lambda { |req, res|
         | 
| 27 | 
            -
                if username
         | 
| 28 | 
            -
                  type, credentials = req.header['proxy-authorization'].first.to_s.split(/\s+/, 2)
         | 
| 29 | 
            -
                  unless "Basic" == type && match_credentials.call(credentials)
         | 
| 30 | 
            -
                    res['proxy-authenticate'] = %{Basic realm="testing"}
         | 
| 31 | 
            -
                    raise WEBrick::HTTPStatus::ProxyAuthenticationRequired
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
                end
         | 
| 34 | 
            -
              }
         | 
| 35 | 
            -
            }
         | 
| 36 | 
            -
             | 
| 37 | 
            -
            proxy = WEBrick::HTTPProxyServer.new(webrick_opts)
         | 
| 38 | 
            -
             | 
| 39 | 
            -
            trap(:TERM) { proxy.shutdown }
         | 
| 40 | 
            -
            trap(:INT) { proxy.shutdown }
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            proxy.start
         |