rest 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rest/client.rb +5 -2
- data/lib/rest/version.rb +1 -1
- data/lib/rest/wrappers/net_http_persistent_wrapper.rb +2 -1
- data/lib/rest/wrappers/typhoeus_wrapper.rb +5 -0
- data/test/tmp.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 880fe5136cd250c97eb7862c93a4b296a4f9b9ad
|
4
|
+
data.tar.gz: 02dac2153fbc8a86bab768b732547604d19a2c21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8087772b56f2ceebcde26485b8b3a16a2e3cf4ff77ba4e1e6c6ac42a512690b53b056d59bc28c1de0c43529da19d5bad2609af15813851f02ed8b9ae347acfb7
|
7
|
+
data.tar.gz: 4ffccb545451c80d261cca8071c41c3f2d69e387fb30419106f7c300832fa82447be3213f6dbfffc39a87b25f3cf4884c4e0353771d016d2a15e8b192e1a291b
|
data/Gemfile.lock
CHANGED
data/lib/rest/client.rb
CHANGED
@@ -50,6 +50,7 @@ module Rest
|
|
50
50
|
class Client
|
51
51
|
|
52
52
|
attr_accessor :options, :logger, :gem
|
53
|
+
attr_reader :wrapper
|
53
54
|
# options:
|
54
55
|
# - :gem => specify gem explicitly
|
55
56
|
#
|
@@ -70,7 +71,7 @@ module Rest
|
|
70
71
|
@logger.debug "Using excon gem."
|
71
72
|
elsif @gem == :typhoeus
|
72
73
|
require File.expand_path('wrappers/typhoeus_wrapper', File.dirname(__FILE__))
|
73
|
-
@wrapper = Rest::Wrappers::TyphoeusWrapper.new
|
74
|
+
@wrapper = Rest::Wrappers::TyphoeusWrapper.new(self)
|
74
75
|
@logger.debug "Using typhoeus gem."
|
75
76
|
elsif @gem == :net_http_persistent
|
76
77
|
require File.expand_path('wrappers/net_http_persistent_wrapper', File.dirname(__FILE__))
|
@@ -79,13 +80,15 @@ module Rest
|
|
79
80
|
elsif @gem == :rest_client
|
80
81
|
require File.expand_path('wrappers/rest_client_wrapper', File.dirname(__FILE__))
|
81
82
|
@wrapper = Rest::Wrappers::RestClientWrapper.new
|
82
|
-
hint = (options[:gem] ? "" : "NOTICE: Please
|
83
|
+
hint = (options[:gem] ? "" : "NOTICE: Please upgrade to Ruby 2.X for optimal performance.")
|
83
84
|
puts hint
|
84
85
|
@logger.debug "Using rest-client gem. #{hint}"
|
86
|
+
RestClient.proxy = options[:http_proxy] if options[:http_proxy]
|
85
87
|
else # use internal client
|
86
88
|
require File.expand_path('wrappers/internal_client_wrapper', File.dirname(__FILE__))
|
87
89
|
@wrapper = Rest::Wrappers::InternalClientWrapper.new
|
88
90
|
@logger.debug "Using rest internal client. #{hint}"
|
91
|
+
InternalClient.proxy = options[:http_proxy] if options[:http_proxy]
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
data/lib/rest/version.rb
CHANGED
@@ -54,7 +54,8 @@ module Rest
|
|
54
54
|
|
55
55
|
def initialize(client)
|
56
56
|
@client = client
|
57
|
-
@http = Net::HTTP::Persistent.new
|
57
|
+
@http = Net::HTTP::Persistent.new('rest_gem')
|
58
|
+
@http.proxy = URI(@client.options[:http_proxy]) if @client.options[:http_proxy]
|
58
59
|
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
59
60
|
end
|
60
61
|
|
@@ -33,6 +33,10 @@ module Rest
|
|
33
33
|
|
34
34
|
class TyphoeusWrapper < BaseWrapper
|
35
35
|
|
36
|
+
def initialize(client)
|
37
|
+
@client = client
|
38
|
+
end
|
39
|
+
|
36
40
|
def default_typhoeus_options
|
37
41
|
req_hash = {}
|
38
42
|
# todo: should change this timeout to longer if it's for posting file
|
@@ -46,6 +50,7 @@ module Rest
|
|
46
50
|
|
47
51
|
def get(url, req_hash={})
|
48
52
|
req_hash = default_typhoeus_options.merge(req_hash)
|
53
|
+
req_hash[:proxy] = @client.options[:http_proxy] if @client.options[:http_proxy]
|
49
54
|
# puts "REQ_HASH=" + req_hash.inspect
|
50
55
|
response = Typhoeus::Request.get(url, req_hash)
|
51
56
|
#p response
|
data/test/tmp.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-http-persistent
|