Skip to content
This repository
Browse code

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
Todd Fisher authored
12  lib/curl/multi.rb
@@ -157,13 +157,17 @@ def http(urls_with_config, multi_options={}, &blk)
157 157
           end
158 158
         end
159 159
 
160  
-        until urls_with_config.empty?
161  
-          m.perform do
  160
+        if urls_with_config.empty?
  161
+          m.perform
  162
+        else
  163
+          until urls_with_config.empty?
  164
+            m.perform do
  165
+              consume_free_handles.call
  166
+            end
162 167
             consume_free_handles.call
163 168
           end
164  
-          consume_free_handles.call
  169
+          free_handles = nil
165 170
         end
166  
-        free_handles = nil 
167 171
       end
168 172
 
169 173
       # call-seq:
21  tests/tc_curl_multi.rb
@@ -385,7 +385,26 @@ def test_multi_easy_http_01
385 385
     end
386 386
   end
387 387
 
388  
-  def test_mutli_recieves_500
  388
+  def test_multi_easy_http_with_max_connects
  389
+        urls = [
  390
+      { :url => TestServlet.url + '?q=1', :method => :get },
  391
+      { :url => TestServlet.url + '?q=2', :method => :get },
  392
+      { :url => TestServlet.url + '?q=3', :method => :get }
  393
+    ]
  394
+    Curl::Multi.http(urls, {:pipeline => true, :max_connects => 1}) do|easy, code, method|
  395
+      assert_equal nil, code
  396
+      case method
  397
+      when :post
  398
+        assert_match /POST/, easy.body_str
  399
+      when :get
  400
+        assert_match /GET/, easy.body_str
  401
+      when :put
  402
+        assert_match /PUT/, easy.body_str
  403
+      end
  404
+    end
  405
+  end
  406
+
  407
+  def test_multi_recieves_500
389 408
     m = Curl::Multi.new
390 409
     e = Curl::Easy.new("http://127.0.0.1:9129/methods")
391 410
     failure = false

0 notes on commit dceafcd

Please sign in to comment.
Something went wrong with that request. Please try again.