Class | Curl::Multi |
In: |
lib/curl/multi.rb
ext/curb_postfield.c |
Parent: | Object |
Set the global default time out for all Curl::Multi Handles. This value is used when libcurl cannot determine a timeout value when calling curl_multi_timeout.
{ :url => 'url1', :method => :post, :post_fields => {'field1' => 'value1', 'field2' => 'value2'} }, { :url => 'url2', :method => :get, :follow_location => true, :max_redirects => 3 }, { :url => 'url3', :method => :put, :put_data => File.open('file.txt','rb') }, { :url => 'url4', :method => :head }
], {:pipeline => true})
Blocking call to issue multiple HTTP requests with varying verb‘s.
urls_with_config: is a hash of url‘s pointing to the easy handle options as well as the special option :method, that can by one of [:get, :post, :put, :delete, :head], when no verb is provided e.g. :method => nil -> GET is used multi_options: options for the multi handle blk: a callback, that yeilds when a handle is completed
Curl::Multi.post([{:url => 'url1', :post_fields => {'field1' => 'value1', 'field2' => 'value2'}}, {:url => 'url2', :post_fields => {'field1' => 'value1', 'field2' => 'value2'}}, {:url => 'url3', :post_fields => {'field1' => 'value1', 'field2' => 'value2'}}], { :follow_location => true, :multipart_form_post => true }, {:pipeline => true }) do|easy| easy_handle_on_request_complete end
Blocking call to POST multiple form‘s in parallel.
urls_with_config: is a hash of url‘s pointing to the postfields to send easy_options: are a set of common options to set on all easy handles multi_options: options to set on the Curl::Multi handle
Curl::Multi.put([{:url => 'url1', :put_data => "some message"}, {:url => 'url2', :put_data => IO.read('filepath')}, {:url => 'url3', :put_data => "maybe another string or socket?"], {:follow_location => true}, {:pipeline => true }) do|easy| easy_handle_on_request_complete end
Blocking call to POST multiple form‘s in parallel.
urls_with_config: is a hash of url‘s pointing to the postfields to send easy_options: are a set of common options to set on all easy handles multi_options: options to set on the Curl::Multi handle
Returns whether or not this Curl::Multi handle is processing any requests. E.g. this returns true when multi.requests.length == 0.
multi.add(easy1) multi.add(easy2)
multi.perform do
# while idle other code my execute here
end
Run multi handles, looping selecting when data can be transfered
Pass a long set to 1 to enable or 0 to disable. Enabling pipelining on a multi handle will make it attempt to perform HTTP Pipelining as far as possible for transfers using this handle. This means that if you add a second request that can use an already existing connection, the second request will be "piped" on the same connection rather than being executed in parallel. (Added in 7.16.0)
multi.add(easy)
# sometime later multi.remove(easy)
Remove an easy handle from a multi stack.
Will raise an exception if the easy handle is not found
Returns an array containing all the active requests on this Curl::Multi object.