1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

:timeout option for RestClient::Resource constructor

This commit is contained in:
Adam Wiggins 2008-12-08 01:47:23 -08:00
parent 1a4d848025
commit e91fd21c1f

View file

@ -12,6 +12,10 @@ module RestClient
# resource = RestClient::Resource.new('http://protected/resource', :user => 'user', :password => 'password')
# resource.delete
#
# With a timeout (seconds):
#
# RestClient::Resource.new('http://slow', :timeout => 10)
#
# You can also use resources to share common headers. For headers keys,
# symbols are converted to strings. Example:
#
@ -38,37 +42,37 @@ module RestClient
end
def get(additional_headers={})
Request.execute(:method => :get,
Request.execute(options.merge(
:method => :get,
:url => url,
:user => user,
:password => password,
:headers => headers.merge(additional_headers))
:headers => headers.merge(additional_headers)
))
end
def post(payload, additional_headers={})
Request.execute(:method => :post,
Request.execute(options.merge(
:method => :post,
:url => url,
:payload => payload,
:user => user,
:password => password,
:headers => headers.merge(additional_headers))
:headers => headers.merge(additional_headers)
))
end
def put(payload, additional_headers={})
Request.execute(:method => :put,
Request.execute(options.merge(
:method => :put,
:url => url,
:payload => payload,
:user => user,
:password => password,
:headers => headers.merge(additional_headers))
:headers => headers.merge(additional_headers)
))
end
def delete(additional_headers={})
Request.execute(:method => :delete,
Request.execute(options.merge(
:method => :delete,
:url => url,
:user => user,
:password => password,
:headers => headers.merge(additional_headers))
:headers => headers.merge(additional_headers)
))
end
def to_s
@ -87,6 +91,10 @@ module RestClient
options[:headers] || {}
end
def timeout
options[:timeout]
end
# Construct a subresource, preserving authentication.
#
# Example: