faraday-http-cache 1.2.0 → 1.2.2

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
  SHA1:
3
- metadata.gz: ed664b05e7052722cfb0f9d0ba7336b6de8ea5b7
4
- data.tar.gz: fece9174d01e39d9e63c92f0ae6ba28c676a3504
3
+ metadata.gz: 0a62aee8278ee280538fcda4370c230496f9aa26
4
+ data.tar.gz: ed354b7f472d84e17c996d2a97c61da81f41bc92
5
5
  SHA512:
6
- metadata.gz: db36959ac2578e4f9559aece670ab1a8fcc58d33d87bceb24dd9ea6871260d0af88ad570907198e01a4d733e146e884d5fca62ffec2223b61d1b2bd6aba8d399
7
- data.tar.gz: de95b997afd0c83d6e1b344e5e00f9bd0e2a6ce57c7d81bbde0bc5a8ac6f4efbe804087c2565c89ec879145c5e06e00ced67d491e77cfe2515c9900817063676
6
+ metadata.gz: fe2d52575496d9f73201deff62c664611c664148a2bde2f01adc1d63074c35ff6dda1103d19171dcb1f114fc1eb563d4235abc7e2439a5d8a6cf0ab88d761a8a
7
+ data.tar.gz: a7c46d882287552df02f7f3f3baf25c9182ac16c47905bef51520e41895d1baebc81f10ea33798d93c51df85593f16c6829fa7169a71df41c12940f81351986c
@@ -54,20 +54,26 @@ module Faraday
54
54
  EVENT_NAME = 'http_cache.faraday'
55
55
 
56
56
  CACHE_STATUSES = [
57
- # The request was not cacheable:
57
+ # The request was not cacheable.
58
58
  :unacceptable,
59
59
 
60
- # The response was cached and can still be used:
60
+ # The response was cached and can still be used.
61
61
  :fresh,
62
62
 
63
- # The response was cached and the server has validated it with a 304 response:
63
+ # The response was cached and the server has validated it with a 304 response.
64
64
  :valid,
65
65
 
66
- # The response was cached but the server could not validate it.
66
+ # The response was cache but was revalidated by the sserver.
67
67
  :invalid,
68
68
 
69
- # No response was found in the cache:
70
- :miss
69
+ # No response was found in the cache.
70
+ :miss,
71
+
72
+ # The response can't be cached.
73
+ :uncacheable,
74
+
75
+ # The request decided to ignore the cache.
76
+ :bypass
71
77
  ]
72
78
 
73
79
  # Public: Initializes a new HttpCache middleware.
@@ -243,6 +249,8 @@ module Faraday
243
249
  updated_payload[:response_headers].update(updated_response_headers)
244
250
  requested_env.update(updated_payload)
245
251
  response = Response.new(updated_payload)
252
+ else
253
+ trace :invalid
246
254
  end
247
255
  store(response)
248
256
  end
@@ -259,7 +267,7 @@ module Faraday
259
267
  end
260
268
 
261
269
  # Internal: Stores the response into the storage.
262
- # If the response isn't cacheable, a trace action 'invalid' will be
270
+ # If the response isn't cacheable, a trace action 'uncacheable' will be
263
271
  # recorded for logging purposes.
264
272
  #
265
273
  # response - a 'Faraday::HttpCache::Response' instance to be stored.
@@ -270,7 +278,7 @@ module Faraday
270
278
  trace :store
271
279
  @storage.write(@request, response)
272
280
  else
273
- trace :invalid
281
+ trace :uncacheable
274
282
  end
275
283
  end
276
284
 
@@ -28,7 +28,7 @@ describe Faraday::HttpCache do
28
28
  client.post('post').body
29
29
  end
30
30
 
31
- it 'does not cache responses with invalid status code' do
31
+ it 'does not cache responses with , status code' do
32
32
  client.get('broken')
33
33
  expect(client.get('broken').body).to eq('2')
34
34
  end
@@ -89,8 +89,8 @@ describe Faraday::HttpCache do
89
89
  client.patch('counter')
90
90
  end
91
91
 
92
- it 'logs that a response with a bad status code is invalid' do
93
- expect(logger).to receive(:debug) { |&block| expect(block.call).to eq('HTTP Cache: [GET /broken] miss, invalid') }
92
+ it 'logs that a response with a bad status code is uncacheable' do
93
+ expect(logger).to receive(:debug) { |&block| expect(block.call).to eq('HTTP Cache: [GET /broken] miss, uncacheable') }
94
94
  client.get('broken')
95
95
  end
96
96
 
@@ -115,8 +115,8 @@ describe Faraday::HttpCache do
115
115
  expect(client.get('private').body).to eq('2')
116
116
  end
117
117
 
118
- it 'logs that a private response is invalid' do
119
- expect(logger).to receive(:debug) { |&block| expect(block.call).to eq('HTTP Cache: [GET /private] miss, invalid') }
118
+ it 'logs that a private response is uncacheable' do
119
+ expect(logger).to receive(:debug) { |&block| expect(block.call).to eq('HTTP Cache: [GET /private] miss, uncacheable') }
120
120
  client.get('private')
121
121
  end
122
122
  end
@@ -140,8 +140,8 @@ describe Faraday::HttpCache do
140
140
  expect(client.get('dontstore').body).to eq('2')
141
141
  end
142
142
 
143
- it 'logs that a response with a no-store directive is invalid' do
144
- expect(logger).to receive(:debug) { |&block| expect(block.call).to eq('HTTP Cache: [GET /dontstore] miss, invalid') }
143
+ it 'logs that a response with a no-store directive is uncacheable' do
144
+ expect(logger).to receive(:debug) { |&block| expect(block.call).to eq('HTTP Cache: [GET /dontstore] miss, uncacheable') }
145
145
  client.get('dontstore')
146
146
  end
147
147
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-http-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Mazza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday