diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb index ddd8fcc..4a35605 100644 --- a/lib/xmlrpc/client.rb +++ b/lib/xmlrpc/client.rb @@ -78,7 +78,9 @@ class Client # # If +use_ssl+ is set to +true+, communication over SSL is enabled. # - # Parameter +timeout+ is the time to wait for a XML-RPC response, defaults to 30. + # Parameter +timeout+ defines the open timeout and read timeout of the + # XML-RPC request. You can set them individually using the methods + # `open_timeout=` and `read_timeout=` def initialize(host=nil, path=nil, port=nil, proxy_host=nil, proxy_port=nil, user=nil, password=nil, use_ssl=nil, timeout=nil) @@ -215,6 +217,14 @@ def timeout=(new_timeout) @http.open_timeout = @timeout end + def open_timeout=(new_timeout) + @http.open_timeout = new_timeout + end + + def read_timeout=(new_timeout) + @http.read_timeout = new_timeout + end + # Changes the user for the Basic Authentication header to +new_user+ def user=(new_user) @user = new_user diff --git a/test/test_client.rb b/test/test_client.rb index ceb01c9..b76df66 100644 --- a/test/test_client.rb +++ b/test/test_client.rb @@ -77,6 +77,22 @@ def initialize(*args) end end + def test_open_timeout= + client = Fake::Client.new 'http://example.org/foo' + assert_equal 30, client.http.open_timeout + + client.open_timeout = 10 + assert_equal 10, client.http.open_timeout + end + + def test_read_timeout= + client = Fake::Client.new 'http://example.org/foo' + assert_equal 30, client.http.read_timeout + + client.read_timeout = 20 + assert_equal 20, client.http.read_timeout + end + def test_new2_host_path_port client = Fake::Client.new2 'http://example.org/foo' host, path, port, *rest = client.args