restful_resource 2.6.1 → 2.7.0

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: 015747ee95ac4e52617a009da36dcccb671aa6f8437662287f9dadf951f2049e
4
- data.tar.gz: c27835d8a584d1d5c228725892ceca06cb215cbdee088d7c2b6884228371aab1
3
+ metadata.gz: 3102663d7afdbed68734466795d237a1b90c16a37cf9001d41511d8949a53545
4
+ data.tar.gz: cc440e90343ddcccdac145f6c8a5c9180f22aacec6c19464af5b14e17bca7f30
5
5
  SHA512:
6
- metadata.gz: 9d987975b117009d80e0179663ab643a24d055220b01f149be44d12024968732166ec9a589d9517f27150630a8794b0e2557b8fe72ff332be8a3472dab74deb6
7
- data.tar.gz: 1cebc647b6ddfca2d0fee0ab9bb9d32ef1820f3d06d613a7417b38f9c28617569bfcfe3f6dac7fe71eff47c8c8b7041876cbc54a90fb6d78438e39ae720cac13
6
+ metadata.gz: 9a854369276af2c44a1c6630994cc7024ab24de35b1a01269492ca41b4f3da85d1df4406ab0d60a202c46b5eddb1d0a4c14b5341a26c40d8baaedf2bebd77d95
7
+ data.tar.gz: c4a34be5f465dfc0186febab93f24c94ea0039a0eb2b8bc700c9e58a02ae38bf0a96c6f3c24d9b57876fe1ab42d73471cacbc00c9b799b5d4dfe0e805b763601
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ tmp
17
17
  .idea
18
18
  *.swp
19
19
  *.swo
20
+ /tags
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ 2.7.0
4
+ ---
5
+
6
+ - Add `X-Client-Start` header on request containing milliseconds since unix epoch
7
+
3
8
  2.6.1
4
9
  ---
10
+
5
11
  - Support only `faraday-0.15.x`
6
12
  - `0.16.x` breaks `faraday-http-cache`
7
13
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- restful_resource (2.6.1)
4
+ restful_resource (2.7.0)
5
5
  activesupport
6
6
  faraday (~> 0.15.0)
7
7
  faraday-cdn-metrics
@@ -42,7 +42,7 @@ GEM
42
42
  faraday_middleware (0.13.1)
43
43
  faraday (>= 0.7.4, < 1.0)
44
44
  ffi (1.11.1)
45
- i18n (1.6.0)
45
+ i18n (1.7.0)
46
46
  concurrent-ruby (~> 1.0)
47
47
  jaro_winkler (1.5.3)
48
48
  link_header (0.0.8)
@@ -94,7 +94,7 @@ GEM
94
94
  tzinfo (1.2.5)
95
95
  thread_safe (~> 0.1)
96
96
  unicode-display_width (1.6.0)
97
- zeitwerk (2.1.10)
97
+ zeitwerk (2.2.0)
98
98
 
99
99
  PLATFORMS
100
100
  ruby
@@ -252,7 +252,7 @@ module RestfulResource
252
252
  req.body = request.body unless request.body.nil?
253
253
  req.url request.url
254
254
 
255
- req.headers = req.headers.merge(request.headers)
255
+ req.headers = req.headers.merge(request.headers).merge(x_client_start: time_current_ms)
256
256
  req.headers = req.headers.merge(x_client_timeout: req.options[:timeout]) if req.options[:timeout]
257
257
  end
258
258
 
@@ -266,8 +266,6 @@ module RestfulResource
266
266
  raise ClientError, request unless response
267
267
 
268
268
  handle_error(request, response)
269
- rescue Faraday::ServerError => e
270
- handle_error(request, e.response)
271
269
  end
272
270
 
273
271
  def handle_error(request, response)
@@ -282,5 +280,9 @@ module RestfulResource
282
280
  else raise HttpClient::OtherHttpError.new(request, response)
283
281
  end
284
282
  end
283
+
284
+ def time_current_ms
285
+ (Time.current.to_f * 1_000.0).to_i
286
+ end
285
287
  end
286
288
  end
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = '2.6.1'.freeze
2
+ VERSION = '2.7.0'.freeze
3
3
  end
@@ -338,4 +338,23 @@ RSpec.describe RestfulResource::HttpClient do
338
338
  end
339
339
  end
340
340
  end
341
+
342
+ describe 'X-Client-Start' do
343
+ let(:now) { Time.current }
344
+ let(:required_headers) { { 'X-Client-Start' => (now.to_f * 1000.0).to_i } }
345
+ let(:http_client) { described_class.new(connection: connection) }
346
+ let(:connection) do
347
+ conn = faraday_connection do |stubs|
348
+ stubs.get('http://httpbin.org/get', required_headers) { |_env| [200, {}, nil] }
349
+ end
350
+ end
351
+
352
+ before { allow(Time).to receive(:current).and_return(now) }
353
+
354
+ it 'sets X-Client-Start correctly' do
355
+ response = http_client.get('http://httpbin.org/get')
356
+
357
+ expect(response.status).to eq 200
358
+ end
359
+ end
341
360
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santoro
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-10-03 00:00:00.000000000 Z
12
+ date: 2019-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler