grac 4.4.1 → 4.5.0
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/lib/grac/client.rb +20 -4
- data/lib/grac/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: 3b2bebcc4e909adb1e0cf7a05e6c710c4de2491ab29c506975d559367c9e1be3
|
|
4
|
+
data.tar.gz: dcd944e2ce073ce3dca7d9b44cc0be1b2e8834bdc1af7de9f1aa7c0b1c7fec32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 108fb0cd4c2a9a0864d71a3b36697c7905ecb034443e49de1b701264f21980c5c469928ebcd44f9289bfdeef60016eb9819db9a757d2f6d64973ea1d8293998c
|
|
7
|
+
data.tar.gz: bdb4308590bf1abf18b0d31a45c208576b79ba9856a19913348e83c1d11957aff0a41e69de589bb651961bdfa340e9977487aaf4eb3771afb5e7cde849e57482
|
data/lib/grac/client.rb
CHANGED
|
@@ -97,6 +97,7 @@ module Grac
|
|
|
97
97
|
}
|
|
98
98
|
apply_proxy_options(request_hash, opts[:proxy])
|
|
99
99
|
apply_ssl_options(request_hash, opts[:ssl])
|
|
100
|
+
apply_multipart_handling(request_hash, opts[:headers])
|
|
100
101
|
|
|
101
102
|
request = ::Typhoeus::Request.new(request_uri, request_hash)
|
|
102
103
|
response = request.run
|
|
@@ -151,6 +152,9 @@ module Grac
|
|
|
151
152
|
when /\Aapplication\/x-www-form-urlencoded/
|
|
152
153
|
# Typhoeus will take care of the encoding when receiving a hash
|
|
153
154
|
return body
|
|
155
|
+
when /\Amultipart\/form-data/
|
|
156
|
+
# Typhoeus will take care of the encoding when receiving a hash
|
|
157
|
+
return body
|
|
154
158
|
else
|
|
155
159
|
# Do not encode other unknown Content-Types either.
|
|
156
160
|
# The default is JSON through the Content-Type header which is set by default.
|
|
@@ -162,7 +166,7 @@ module Grac
|
|
|
162
166
|
callee = self
|
|
163
167
|
|
|
164
168
|
@options[:middleware].reverse.each do |mw|
|
|
165
|
-
if mw.
|
|
169
|
+
if mw.is_a?(Array)
|
|
166
170
|
middleware_class = mw[0]
|
|
167
171
|
params = mw[1..-1]
|
|
168
172
|
|
|
@@ -220,17 +224,17 @@ module Grac
|
|
|
220
224
|
def postprocessing(data, processing = nil)
|
|
221
225
|
return data if @options[:postprocessing].nil? || @options[:postprocessing].empty?
|
|
222
226
|
|
|
223
|
-
if data.
|
|
227
|
+
if data.is_a?(Hash)
|
|
224
228
|
data.each do |key, value|
|
|
225
229
|
processing = nil
|
|
226
230
|
regexp = @options[:postprocessing].keys.detect { |pattern| pattern.match?(key) }
|
|
227
231
|
|
|
228
|
-
if
|
|
232
|
+
if regexp != nil
|
|
229
233
|
processing = @options[:postprocessing][regexp]
|
|
230
234
|
end
|
|
231
235
|
data[key] = postprocessing(value, processing)
|
|
232
236
|
end
|
|
233
|
-
elsif data.
|
|
237
|
+
elsif data.is_a?(Array)
|
|
234
238
|
data.each_with_index do |value, index|
|
|
235
239
|
data[index] = postprocessing(value, processing)
|
|
236
240
|
end
|
|
@@ -279,5 +283,17 @@ module Grac
|
|
|
279
283
|
request_hash[:cainfo] = ssl[:ca_info] if ssl[:ca_info] != nil
|
|
280
284
|
end
|
|
281
285
|
|
|
286
|
+
def apply_multipart_handling(request_hash, headers)
|
|
287
|
+
return if headers == nil
|
|
288
|
+
return if !headers['Content-Type']
|
|
289
|
+
return if !headers['Content-Type'].include?('multipart/form-data')
|
|
290
|
+
|
|
291
|
+
request_hash[:multipart] = true
|
|
292
|
+
# Typhoeus does not expect a Content-Type header for multipart requests.
|
|
293
|
+
# It sets the correct one itself including the boundary.
|
|
294
|
+
# Therefore we need to remove the Content-Type header from the request.
|
|
295
|
+
request_hash[:headers] = headers.reject { |k, _| k == 'Content-Type' }
|
|
296
|
+
end
|
|
297
|
+
|
|
282
298
|
end
|
|
283
299
|
end
|
data/lib/grac/version.rb
CHANGED