code-ruby 1.8.13 → 1.8.15
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/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/code/object/http.rb +20 -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: 1f71684c4dc7d49cba70fd38bcd64ad838a0f3c303dbb492364e2cd7a8d66d55
|
|
4
|
+
data.tar.gz: 1debf69960b9da25c30f2523aa64df84e7ee0d6fc5b4965d7ceb956c66244a3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dfb5cc19d6334ca14906b74be16ce26d6bec269e6f78030ad3ce6ef00fa0ded8ade6b6af3c6fb0c0e39aa8849cc64425fec6ee95e669ab8f50cd9d5dd866066
|
|
7
|
+
data.tar.gz: abe4ea08744984d2f84f099dedb81e31b041b3d19a97fa173655f727cdda435d78a790bd5b8601f068ed3c953a7c28ebc7624a2a3ca573de1456ab113af36927
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.8.
|
|
1
|
+
1.8.15
|
data/lib/code/object/http.rb
CHANGED
|
@@ -11,7 +11,11 @@ class Code
|
|
|
11
11
|
body: String.maybe,
|
|
12
12
|
username: String.maybe,
|
|
13
13
|
password: String.maybe,
|
|
14
|
-
data: Dictionary.maybe
|
|
14
|
+
data: Dictionary.maybe,
|
|
15
|
+
timeout: (Integer | Decimal).maybe,
|
|
16
|
+
open_timeout: (Integer | Decimal).maybe,
|
|
17
|
+
read_timeout: (Integer | Decimal).maybe,
|
|
18
|
+
write_timeout: (Integer | Decimal).maybe
|
|
15
19
|
}
|
|
16
20
|
].freeze
|
|
17
21
|
|
|
@@ -80,6 +84,7 @@ class Code
|
|
|
80
84
|
not_extended: 510,
|
|
81
85
|
network_authentication_required: 511
|
|
82
86
|
}.freeze
|
|
87
|
+
DEFAULT_TIMEOUT = 1.hour.to_f
|
|
83
88
|
|
|
84
89
|
def self.call(**args)
|
|
85
90
|
code_operator = args.fetch(:operator, nil).to_code
|
|
@@ -160,6 +165,10 @@ class Code
|
|
|
160
165
|
body = options.code_get("body").to_s
|
|
161
166
|
headers = options.code_get("headers").raw || {}
|
|
162
167
|
data = options.code_get("data").raw || {}
|
|
168
|
+
timeout = options.code_get("timeout")
|
|
169
|
+
open_timeout = options.code_get("open_timeout")
|
|
170
|
+
read_timeout = options.code_get("read_timeout")
|
|
171
|
+
write_timeout = options.code_get("write_timeout")
|
|
163
172
|
query = options.code_get("query").raw || {}
|
|
164
173
|
query = query.to_a.flatten.map(&:to_s).each_slice(2).to_h.to_query
|
|
165
174
|
|
|
@@ -174,6 +183,16 @@ class Code
|
|
|
174
183
|
uri = ::URI.parse(url)
|
|
175
184
|
http = ::Net::HTTP.new(uri.host, uri.port)
|
|
176
185
|
http.use_ssl = true if uri.scheme == "https"
|
|
186
|
+
default_timeout = timeout.nothing? ? DEFAULT_TIMEOUT : timeout.to_f
|
|
187
|
+
open_timeout_value = open_timeout.nothing? ? default_timeout : open_timeout.to_f
|
|
188
|
+
read_timeout_value = read_timeout.nothing? ? default_timeout : read_timeout.to_f
|
|
189
|
+
write_timeout_value = write_timeout.nothing? ? default_timeout : write_timeout.to_f
|
|
190
|
+
|
|
191
|
+
http.open_timeout = open_timeout_value if open_timeout_value
|
|
192
|
+
http.read_timeout = read_timeout_value if read_timeout_value
|
|
193
|
+
if http.respond_to?(:write_timeout=) && write_timeout_value
|
|
194
|
+
http.write_timeout = write_timeout_value
|
|
195
|
+
end
|
|
177
196
|
|
|
178
197
|
request_class =
|
|
179
198
|
case verb
|