yamlrpc 0.1.080701110311 → 0.1.080704174553
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yamlrpc/client.rb +10 -1
- metadata +2 -2
data/lib/yamlrpc/client.rb
CHANGED
@@ -14,14 +14,20 @@ module YamlRpc
|
|
14
14
|
class Client
|
15
15
|
|
16
16
|
DEFAULT_FORM_DATA_ROOT = :yaml_rpc
|
17
|
+
DEFAULT_OPEN_TIMEOUT = 120 # 2 minutes
|
18
|
+
DEFAULT_READ_TIMEOUT = 120 # 2 minutes
|
17
19
|
|
18
20
|
attr_accessor :url
|
19
21
|
attr_accessor :form_data_root
|
22
|
+
attr_accessor :open_timeout
|
23
|
+
attr_accessor :read_timeout
|
20
24
|
|
21
25
|
# * <tt>url</tt> Root url, ie. "http://my.com/something/"; YamlRpc#some_method(:foo => 'bar') will POST to http://my.com/something/some_method with { :foo => 'bar' } params
|
22
26
|
# * <tt>options</tt>
|
23
27
|
# * <tt>:form_data_root</tt> Default to :yamlrpc, meaning all params are passed inside :yamlrpc form field
|
24
28
|
def initialize(url, options = {})
|
29
|
+
@open_timeout = options[:open_timeout]
|
30
|
+
@read_timeout = options[:read_timeout]
|
25
31
|
@url = url
|
26
32
|
@form_data_root = options.has_key?(:form_data_root) ? options[:form_data_root] : DEFAULT_FORM_DATA_ROOT
|
27
33
|
end
|
@@ -40,7 +46,10 @@ module YamlRpc
|
|
40
46
|
url = URI.parse("#{@url}#{add_url}")
|
41
47
|
req = Net::HTTP::Post.new(url.path)
|
42
48
|
req.set_form_data(args_to_form_data(args), ';')
|
43
|
-
|
49
|
+
http = Net::HTTP.new(url.host, url.port)
|
50
|
+
http.open_timeout = @open_timeout
|
51
|
+
http.read_timeout = @read_timeout
|
52
|
+
res = http.start { |http| http.request(req) }
|
44
53
|
case res
|
45
54
|
when Net::HTTPSuccess
|
46
55
|
YAML::load(res.body)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamlrpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.080704174553
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mirek Rusin
|
@@ -9,7 +9,7 @@ autorequire: yamlrpc
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-07-
|
12
|
+
date: 2008-07-04 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|