Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #115 from chuyeow/multi

Curl::Multi.http doesn't actually call perform when :max_connects >= number of requests
  • Loading branch information...
commit dceafcd931c4fb7ad2c8d356537358fd1286e4ae 2 parents c57e9aa + a49596d
@taf2 authored
Showing with 28 additions and 5 deletions.
  1. +8 −4 lib/curl/multi.rb
  2. +20 −1 tests/tc_curl_multi.rb
View
12 lib/curl/multi.rb
@@ -157,13 +157,17 @@ def http(urls_with_config, multi_options={}, &blk)
end
end
- until urls_with_config.empty?
- m.perform do
+ if urls_with_config.empty?
+ m.perform
+ else
+ until urls_with_config.empty?
+ m.perform do
+ consume_free_handles.call
+ end
consume_free_handles.call
end
- consume_free_handles.call
+ free_handles = nil
end
- free_handles = nil
end
# call-seq:
View
21 tests/tc_curl_multi.rb
@@ -385,7 +385,26 @@ def test_multi_easy_http_01
end
end
- def test_mutli_recieves_500
+ def test_multi_easy_http_with_max_connects
+ urls = [
+ { :url => TestServlet.url + '?q=1', :method => :get },
+ { :url => TestServlet.url + '?q=2', :method => :get },
+ { :url => TestServlet.url + '?q=3', :method => :get }
+ ]
+ Curl::Multi.http(urls, {:pipeline => true, :max_connects => 1}) do|easy, code, method|
+ assert_equal nil, code
+ case method
+ when :post
+ assert_match /POST/, easy.body_str
+ when :get
+ assert_match /GET/, easy.body_str
+ when :put
+ assert_match /PUT/, easy.body_str
+ end
+ end
+ end
+
+ def test_multi_recieves_500
m = Curl::Multi.new
e = Curl::Easy.new("http://127.0.0.1:9129/methods")
failure = false
Please sign in to comment.
Something went wrong with that request. Please try again.