pact 1.67.4 → 1.67.5
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/CHANGELOG.md +7 -0
- data/lib/pact/hal/http_client.rb +19 -1
- data/lib/pact/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8be91a33981b95189c08f545d3746c76f2f2ad8642777f753cc3b414233986de
|
|
4
|
+
data.tar.gz: 1bc7d8a6e8a08c47b79e73f68e0caed9585a0eafb0bc316a4e589f2b3f9028a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a73f8cf2aa2956f7e0c7ed2dc8ab35fefbf1b7a2b0ab88d21bb3936a4761ae60d2fd622c4f2a767f2b6e75837556aeb055011667def9a90b8fbe1f9df74bf0f9
|
|
7
|
+
data.tar.gz: e27d62a8822b43ded6ccd48b926c2833292617834c7c2b8dda45d93a26a769d1093909d87921f8c15962445d3ef2012b1df2d5417ed7a07259a4275862c9f4b9
|
data/CHANGELOG.md
CHANGED
data/lib/pact/hal/http_client.rb
CHANGED
|
@@ -6,6 +6,18 @@ require 'openssl'
|
|
|
6
6
|
|
|
7
7
|
module Pact
|
|
8
8
|
module Hal
|
|
9
|
+
class RetriableHttpStatusError < StandardError
|
|
10
|
+
RETRIABLE_STATUS_CODES = [502, 503, 504].freeze
|
|
11
|
+
|
|
12
|
+
attr_reader :status_code, :response_body
|
|
13
|
+
|
|
14
|
+
def initialize status_code, response_body
|
|
15
|
+
@status_code = status_code
|
|
16
|
+
@response_body = response_body
|
|
17
|
+
super("HTTP #{status_code} error: #{response_body}")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
9
21
|
class HttpClient
|
|
10
22
|
attr_accessor :username, :password, :verbose, :token
|
|
11
23
|
|
|
@@ -65,9 +77,15 @@ module Pact
|
|
|
65
77
|
end
|
|
66
78
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
67
79
|
end
|
|
68
|
-
http.start do |http|
|
|
80
|
+
result = http.start do |http|
|
|
69
81
|
http.request request
|
|
70
82
|
end
|
|
83
|
+
|
|
84
|
+
# Raise error on specific 5xx status codes to trigger retry
|
|
85
|
+
status_code = result.code.to_i
|
|
86
|
+
raise RetriableHttpStatusError.new(status_code, result.body) if RetriableHttpStatusError::RETRIABLE_STATUS_CODES.include?(status_code)
|
|
87
|
+
|
|
88
|
+
result
|
|
71
89
|
end
|
|
72
90
|
Response.new(response)
|
|
73
91
|
end
|
data/lib/pact/version.rb
CHANGED