faraday-http-cache 2.4.1 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f9734c5eda496aee6fc6d189e27f9e39b43600ffb467976649ad3f7046a8efc
4
- data.tar.gz: 1a4d2d137c3ec0a97790cc4b5bcb706f7e0c2af0d0700e0ae03dfc79f5e2bdba
3
+ metadata.gz: 69e426c03cf04e5a7be4211fbed70c2aa236c3e31655aa9f742ee85351a27d00
4
+ data.tar.gz: 6954402565ff5652d96c90bb696c8bb65e8d1dc6178d985d6bbd89171893cb75
5
5
  SHA512:
6
- metadata.gz: f93240786d8c3b8012cce14545e2f0f34f1bb12811da4edc549ad145284712b59380dac02f91ed6170d19af7af220e48d905a31a1159129d2b32b45799251df6
7
- data.tar.gz: 8b2480bebc178003743ca2e0535966ad617349ef7ead2f7b5907f00d4580ba990332472d2ac393dc6b5bd79b787d8d560e5d772f9bfc1faca76ac6b34a5061d7
6
+ metadata.gz: 60fedd1b2af68503eaf8b108a196ee237f74285dc12e9f526af3a43929ea297db602f357693fcaa9320b46400d1b4c7f08921ea16ebd8a51cd738d0b71a8b1eb
7
+ data.tar.gz: 9eb9c0b6b484099240d29e81bc0335777d895f88c084b29561b2cff9551bf0f36a3afa7aafa096dcadee43cce5d1a9f5583010d461e029b9e4a50257b602b5e5
@@ -142,7 +142,8 @@ module Faraday
142
142
  {
143
143
  status: @payload[:status],
144
144
  body: @payload[:body],
145
- response_headers: @payload[:response_headers]
145
+ response_headers: @payload[:response_headers],
146
+ reason_phrase: @payload[:reason_phrase]
146
147
  }
147
148
  end
148
149
 
@@ -99,7 +99,7 @@ module Faraday
99
99
  vary = headers['Vary'].to_s
100
100
 
101
101
  vary.empty? || (vary != '*' && vary.split(/[\s,]+/).all? do |header|
102
- request.headers[header] == cached_request[:headers][header]
102
+ request.headers[header] == (cached_request[:headers][header] || cached_request[:headers][header.downcase])
103
103
  end)
104
104
  end
105
105
 
@@ -301,7 +301,8 @@ module Faraday
301
301
  {
302
302
  status: hash[:status],
303
303
  body: hash[:body] || hash[:response_body],
304
- response_headers: hash[:response_headers]
304
+ response_headers: hash[:response_headers],
305
+ reason_phrase: hash[:reason_phrase]
305
306
  }
306
307
  end
307
308
 
@@ -200,7 +200,7 @@ describe Faraday::HttpCache::Response do
200
200
  end
201
201
 
202
202
  describe 'response unboxing' do
203
- subject { described_class.new(status: 200, response_headers: {}, body: 'Hi!') }
203
+ subject { described_class.new(status: 200, response_headers: {}, body: 'Hi!', reason_phrase: 'Success') }
204
204
 
205
205
  let(:env) { { method: :get } }
206
206
  let(:response) { subject.to_response(env) }
@@ -224,6 +224,10 @@ describe Faraday::HttpCache::Response do
224
224
  it 'merges the body' do
225
225
  expect(response.body).to eq('Hi!')
226
226
  end
227
+
228
+ it 'merges the reason phrase' do
229
+ expect(response.reason_phrase).to eq('Success') if response.respond_to?(:reason_phrase)
230
+ end
227
231
  end
228
232
 
229
233
  describe 'remove age before caching and normalize max-age if non-zero age present' do
@@ -86,6 +86,24 @@ describe Faraday::HttpCache::Strategies::ByUrl do
86
86
 
87
87
  expect(subject.read(request)).to be_a(Faraday::HttpCache::Response)
88
88
  end
89
+
90
+ context 'with a Vary header in the response in a different case than the matching request header' do
91
+ let(:request) do
92
+ Faraday::HttpCache::Request.new(
93
+ method: :get,
94
+ url: 'http://test/index',
95
+ headers: Faraday::Utils::Headers.new({ 'accept' => 'application/json' })
96
+ )
97
+ end
98
+ let(:response) do
99
+ Faraday::HttpCache::Response.new(response_headers: Faraday::Utils::Headers.new({ vary: 'Accept' }))
100
+ end
101
+
102
+ it 'reads stored message' do
103
+ subject.write(request, response)
104
+ expect(subject.read(request)).to be_a(Faraday::HttpCache::Response)
105
+ end
106
+ end
89
107
  end
90
108
 
91
109
  context 'with the JSON serializer' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-http-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Mazza
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-08-08 00:00:00.000000000 Z
13
+ date: 2024-01-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubygems_version: 3.2.3
84
+ rubygems_version: 3.4.10
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: A Faraday middleware that stores and validates cache expiration.