faraday 2.9.0 → 2.9.1
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/Rakefile +3 -0
- data/lib/faraday/adapter.rb +1 -1
- data/lib/faraday/connection.rb +2 -2
- data/lib/faraday/options/env.rb +1 -1
- data/lib/faraday/response/json.rb +2 -1
- data/lib/faraday/utils/headers.rb +8 -2
- data/lib/faraday/version.rb +1 -1
- data/spec/faraday/params_encoders/nested_spec.rb +2 -1
- data/spec/faraday/response/json_spec.rb +17 -0
- data/spec/faraday/utils/headers_spec.rb +9 -0
- data/spec/faraday_spec.rb +3 -1
- metadata +4 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fbbd7a7b6e5382874543228f830a4a39eb1a361a1bfcd62b6e2f0eb263419745
         | 
| 4 | 
            +
              data.tar.gz: 60e27b5daa918f03860755e49e121729478956eac286636b50cc116118a9936d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9fff33c6bfa400da8b05d91329bb69fda8e09b0b3d686651017b6025f947a98fc4e4c3608af72a5e814e40fb5da701bd6b29f53a9768ee27820e2238c33a9840
         | 
| 7 | 
            +
              data.tar.gz: bd9a550f1f0d99284e9d619749396fa32ef00a0febd22f700e0f2ce5e9675f73d66d18e2302eb987f384b9bbb39e2f8b317546f79dcce2a60b5ad00cf364d953
         | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/faraday/adapter.rb
    CHANGED
    
    
    
        data/lib/faraday/connection.rb
    CHANGED
    
    | @@ -423,8 +423,8 @@ module Faraday | |
| 423 423 | 
             
                #
         | 
| 424 424 | 
             
                # @param method [Symbol] HTTP method.
         | 
| 425 425 | 
             
                # @param url [String, URI, nil] String or URI to access.
         | 
| 426 | 
            -
                # @param body [String, nil] The request body that will eventually be converted to
         | 
| 427 | 
            -
                #             a string.
         | 
| 426 | 
            +
                # @param body [String, Hash, Array, nil] The request body that will eventually be converted to
         | 
| 427 | 
            +
                #             a string; middlewares can be used to support more complex types.
         | 
| 428 428 | 
             
                # @param headers [Hash, nil] unencoded HTTP header key/value pairs.
         | 
| 429 429 | 
             
                #
         | 
| 430 430 | 
             
                # @return [Faraday::Response]
         | 
    
        data/lib/faraday/options/env.rb
    CHANGED
    
    | @@ -169,7 +169,7 @@ module Faraday | |
| 169 169 | 
             
                def stream_response(&block)
         | 
| 170 170 | 
             
                  size = 0
         | 
| 171 171 | 
             
                  yielded = false
         | 
| 172 | 
            -
                  block_result = block.call do |chunk| | 
| 172 | 
            +
                  block_result = block.call do |chunk|
         | 
| 173 173 | 
             
                    if chunk.bytesize.positive? || size.positive?
         | 
| 174 174 | 
             
                      yielded = true
         | 
| 175 175 | 
             
                      size += chunk.bytesize
         | 
| @@ -60,7 +60,8 @@ module Faraday | |
| 60 60 | 
             
                    @decoder_options =
         | 
| 61 61 | 
             
                      if @decoder_options.is_a?(Array) && @decoder_options.size >= 2
         | 
| 62 62 | 
             
                        @decoder_options.slice(0, 2)
         | 
| 63 | 
            -
                      elsif @decoder_options | 
| 63 | 
            +
                      elsif @decoder_options&.respond_to?(:load) # rubocop:disable Lint/RedundantSafeNavigation
         | 
| 64 | 
            +
                        # In some versions of Rails, `nil` responds to `load` - hence the safe navigation check above
         | 
| 64 65 | 
             
                        [@decoder_options, :load]
         | 
| 65 66 | 
             
                      else
         | 
| 66 67 | 
             
                        [::JSON, :parse]
         | 
| @@ -62,10 +62,10 @@ module Faraday | |
| 62 62 | 
             
                    super(key, val)
         | 
| 63 63 | 
             
                  end
         | 
| 64 64 |  | 
| 65 | 
            -
                  def fetch(key,  | 
| 65 | 
            +
                  def fetch(key, ...)
         | 
| 66 66 | 
             
                    key = KeyMap[key]
         | 
| 67 67 | 
             
                    key = @names.fetch(key.downcase, key)
         | 
| 68 | 
            -
                    super(key,  | 
| 68 | 
            +
                    super(key, ...)
         | 
| 69 69 | 
             
                  end
         | 
| 70 70 |  | 
| 71 71 | 
             
                  def delete(key)
         | 
| @@ -77,6 +77,12 @@ module Faraday | |
| 77 77 | 
             
                    super(key)
         | 
| 78 78 | 
             
                  end
         | 
| 79 79 |  | 
| 80 | 
            +
                  def dig(key, *rest)
         | 
| 81 | 
            +
                    key = KeyMap[key]
         | 
| 82 | 
            +
                    key = @names.fetch(key.downcase, key)
         | 
| 83 | 
            +
                    super(key, *rest)
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
             | 
| 80 86 | 
             
                  def include?(key)
         | 
| 81 87 | 
             
                    @names.include? key.downcase
         | 
| 82 88 | 
             
                  end
         | 
    
        data/lib/faraday/version.rb
    CHANGED
    
    
| @@ -62,7 +62,8 @@ RSpec.describe Faraday::NestedParamsEncoder do | |
| 62 62 | 
             
              it 'encodes rack compat' do
         | 
| 63 63 | 
             
                params   = { a: [{ one: '1', two: '2' }, '3', ''] }
         | 
| 64 64 | 
             
                result   = Faraday::Utils.unescape(Faraday::NestedParamsEncoder.encode(params)).split('&')
         | 
| 65 | 
            -
                 | 
| 65 | 
            +
                escaped = Rack::Utils.build_nested_query(params)
         | 
| 66 | 
            +
                expected = Rack::Utils.unescape(escaped).split('&')
         | 
| 66 67 | 
             
                expect(result).to match_array(expected)
         | 
| 67 68 | 
             
              end
         | 
| 68 69 |  | 
| @@ -184,6 +184,23 @@ RSpec.describe Faraday::Response::Json, type: :response do | |
| 184 184 | 
             
                    response = process(body)
         | 
| 185 185 | 
             
                    expect(response.body).to eq(result)
         | 
| 186 186 | 
             
                  end
         | 
| 187 | 
            +
             | 
| 188 | 
            +
                  it 'passes relevant options to JSON parse even when nil responds to :load' do
         | 
| 189 | 
            +
                    original_allow_message_expectations_on_nil = RSpec::Mocks.configuration.allow_message_expectations_on_nil
         | 
| 190 | 
            +
                    RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
         | 
| 191 | 
            +
                    allow(nil).to receive(:respond_to?)
         | 
| 192 | 
            +
                      .with(:load)
         | 
| 193 | 
            +
                      .and_return(true)
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                    expect(JSON).to receive(:parse)
         | 
| 196 | 
            +
                      .with(body, { symbolize_names: true })
         | 
| 197 | 
            +
                      .and_return(result)
         | 
| 198 | 
            +
             | 
| 199 | 
            +
                    response = process(body)
         | 
| 200 | 
            +
                    expect(response.body).to eq(result)
         | 
| 201 | 
            +
                  ensure
         | 
| 202 | 
            +
                    RSpec::Mocks.configuration.allow_message_expectations_on_nil = original_allow_message_expectations_on_nil
         | 
| 203 | 
            +
                  end
         | 
| 187 204 | 
             
                end
         | 
| 188 205 | 
             
              end
         | 
| 189 206 | 
             
            end
         | 
| @@ -56,6 +56,15 @@ RSpec.describe Faraday::Utils::Headers do | |
| 56 56 | 
             
                it { expect(subject.delete('content-type')).to be_nil }
         | 
| 57 57 | 
             
              end
         | 
| 58 58 |  | 
| 59 | 
            +
              describe '#dig' do
         | 
| 60 | 
            +
                before { subject['Content-Type'] = 'application/json' }
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                it { expect(subject&.dig('Content-Type')).to eq('application/json') }
         | 
| 63 | 
            +
                it { expect(subject&.dig('CONTENT-TYPE')).to eq('application/json') }
         | 
| 64 | 
            +
                it { expect(subject&.dig(:content_type)).to eq('application/json') }
         | 
| 65 | 
            +
                it { expect(subject&.dig('invalid')).to be_nil }
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 59 68 | 
             
              describe '#parse' do
         | 
| 60 69 | 
             
                context 'when response headers leave http status line out' do
         | 
| 61 70 | 
             
                  let(:headers) { "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" }
         | 
    
        data/spec/faraday_spec.rb
    CHANGED
    
    | @@ -19,7 +19,9 @@ RSpec.describe Faraday do | |
| 19 19 |  | 
| 20 20 | 
             
                it 'uses method_missing on Faraday if there is no proxyable method' do
         | 
| 21 21 | 
             
                  expected_message =
         | 
| 22 | 
            -
                    if RUBY_VERSION >= '3. | 
| 22 | 
            +
                    if RUBY_VERSION >= '3.4'
         | 
| 23 | 
            +
                      "undefined method 'this_method_does_not_exist' for module Faraday"
         | 
| 24 | 
            +
                    elsif RUBY_VERSION >= '3.3'
         | 
| 23 25 | 
             
                      "undefined method `this_method_does_not_exist' for module Faraday"
         | 
| 24 26 | 
             
                    else
         | 
| 25 27 | 
             
                      "undefined method `this_method_does_not_exist' for Faraday:Module"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: faraday
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.9. | 
| 4 | 
            +
              version: 2.9.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - "@technoweenie"
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire: 
         | 
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2024- | 
| 13 | 
            +
            date: 2024-06-05 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: faraday-net_http
         | 
| @@ -117,7 +117,7 @@ licenses: | |
| 117 117 | 
             
            - MIT
         | 
| 118 118 | 
             
            metadata:
         | 
| 119 119 | 
             
              homepage_uri: https://lostisland.github.io/faraday
         | 
| 120 | 
            -
              changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.9. | 
| 120 | 
            +
              changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.9.1
         | 
| 121 121 | 
             
              source_code_uri: https://github.com/lostisland/faraday
         | 
| 122 122 | 
             
              bug_tracker_uri: https://github.com/lostisland/faraday/issues
         | 
| 123 123 | 
             
            post_install_message: 
         | 
| @@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 136 136 | 
             
                - !ruby/object:Gem::Version
         | 
| 137 137 | 
             
                  version: '0'
         | 
| 138 138 | 
             
            requirements: []
         | 
| 139 | 
            -
            rubygems_version: 3.5. | 
| 139 | 
            +
            rubygems_version: 3.5.9
         | 
| 140 140 | 
             
            signing_key: 
         | 
| 141 141 | 
             
            specification_version: 4
         | 
| 142 142 | 
             
            summary: HTTP/REST API client library.
         |