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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +3 -3
- data/lib/restful_resource/http_client.rb +5 -3
- data/lib/restful_resource/version.rb +1 -1
- data/spec/restful_resource/http_client_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3102663d7afdbed68734466795d237a1b90c16a37cf9001d41511d8949a53545
|
4
|
+
data.tar.gz: cc440e90343ddcccdac145f6c8a5c9180f22aacec6c19464af5b14e17bca7f30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a854369276af2c44a1c6630994cc7024ab24de35b1a01269492ca41b4f3da85d1df4406ab0d60a202c46b5eddb1d0a4c14b5341a26c40d8baaedf2bebd77d95
|
7
|
+
data.tar.gz: c4a34be5f465dfc0186febab93f24c94ea0039a0eb2b8bc700c9e58a02ae38bf0a96c6f3c24d9b57876fe1ab42d73471cacbc00c9b799b5d4dfe0e805b763601
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
restful_resource (2.
|
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.
|
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.
|
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
|
@@ -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.
|
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-
|
12
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|