blackstack_commons 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/functions.rb +15 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70a80ef69b1f559548bf1b9a5200bef942849a59
|
4
|
+
data.tar.gz: 912b1b9564750ad842219ea1caff941269dd1779
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f6d50eef3b92f6d230ec2bcf0465d645da6eecf5783aff358a55a17a444414a44ccf5907efad0971859ecb0128f7083fc6c870703df3de0369def02da9d7982
|
7
|
+
data.tar.gz: d99124b3868f30b715032814496eb542f11ef625dc761a3db21542dc35a1a6f1e4695621c036abb2156dae328c99d6983bb84ca216d2726fa9c20bab50218724
|
data/lib/functions.rb
CHANGED
@@ -448,7 +448,8 @@ module BlackStack
|
|
448
448
|
SUCCESS = 'success'
|
449
449
|
|
450
450
|
# New call_get
|
451
|
-
def self.call_get(
|
451
|
+
def self.call_get(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE)
|
452
|
+
uri = URI(url)
|
452
453
|
uri.query = URI.encode_www_form(params)
|
453
454
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
|
454
455
|
req = Net::HTTP::Get.new uri
|
@@ -463,19 +464,20 @@ module BlackStack
|
|
463
464
|
end
|
464
465
|
|
465
466
|
# New call_post
|
466
|
-
def self.call_post(
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
467
|
+
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE)
|
468
|
+
uri = URI(url)
|
469
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => ssl_verify_mode) do |http|
|
470
|
+
req = Net::HTTP::Post.new(uri)
|
471
|
+
req['Content-Type'] = 'application/json'
|
472
|
+
req.set_form_data(params)
|
473
|
+
res = http.request req
|
474
|
+
case res
|
475
|
+
when Net::HTTPSuccess then res
|
476
|
+
when Net::HTTPRedirection then BlackStack::Netting::call_post(URI(res['location']), params)
|
477
|
+
else
|
478
|
+
res.error!
|
478
479
|
end
|
480
|
+
end
|
479
481
|
end
|
480
482
|
|
481
483
|
#
|