curb 0.5.7.0 → 0.5.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of curb might be problematic. Click here for more details.

data/ext/curb.h CHANGED
@@ -20,11 +20,11 @@
20
20
  #include "curb_macros.h"
21
21
 
22
22
  // These should be managed from the Rake 'release' task.
23
- #define CURB_VERSION "0.5.7.0"
24
- #define CURB_VER_NUM 570
23
+ #define CURB_VERSION "0.5.8.0"
24
+ #define CURB_VER_NUM 580
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 5
27
- #define CURB_VER_MIC 7
27
+ #define CURB_VER_MIC 8
28
28
  #define CURB_VER_PATCH 0
29
29
 
30
30
 
@@ -1778,7 +1778,8 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1778
1778
 
1779
1779
  VALUE ret;
1780
1780
  VALUE multi = ruby_curl_multi_new(cCurlMulti);
1781
- ruby_curl_multi_add(multi, self);
1781
+
1782
+ rb_funcall(multi, rb_intern("add"), 1, self );
1782
1783
  ret = rb_funcall(multi, rb_intern("perform"), 0);
1783
1784
 
1784
1785
  /* check for errors in the easy response and raise exceptions if anything went wrong and their is no on_failure handler */
@@ -214,16 +214,12 @@ VALUE ruby_curl_multi_add(VALUE self, VALUE easy) {
214
214
  ruby_curl_easy_setup( rbce, &(rbce->bodybuf), &(rbce->headerbuf), &(rbce->curl_headers) );
215
215
 
216
216
  rbcm->active++;
217
- if (mcode == CURLM_CALL_MULTI_PERFORM) {
218
- curl_multi_perform(rbcm->handle, &(rbcm->running));
219
- }
220
217
 
221
- rb_hash_aset( rbcm->requests, easy, easy );
222
- // active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
218
+ /* Increase the running count, so that the perform loop keeps running.
219
+ * If this number is not correct, the next call to curl_multi_perform will correct it. */
220
+ rbcm->running++;
223
221
 
224
- if (rbcm->active > rbcm->running) {
225
- rb_curl_multi_read_info(self, rbcm->handle);
226
- }
222
+ rb_hash_aset( rbcm->requests, easy, easy );
227
223
 
228
224
  return self;
229
225
  }
@@ -21,9 +21,6 @@ typedef struct {
21
21
  extern VALUE cCurlMulti;
22
22
  void init_curb_multi();
23
23
  VALUE ruby_curl_multi_new(VALUE klass);
24
- VALUE ruby_curl_multi_perform(int argc, VALUE *argv, VALUE self);
25
- VALUE ruby_curl_multi_add(VALUE self, VALUE easy);
26
- VALUE ruby_curl_multi_remove(VALUE self, VALUE easy);
27
24
 
28
25
 
29
26
  #endif
@@ -25,7 +25,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
25
25
  m.add( c2 )
26
26
 
27
27
  m.perform
28
-
28
+
29
29
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, d1)
30
30
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, d2)
31
31
 
@@ -49,7 +49,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
49
49
 
50
50
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, c1.body_str)
51
51
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, c2.body_str)
52
-
52
+
53
53
  m = nil
54
54
 
55
55
  end
@@ -74,7 +74,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
74
74
  n.times do|i|
75
75
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, responses[i], "response #{i}")
76
76
  end
77
-
77
+
78
78
  m = nil
79
79
  end
80
80
 
@@ -98,52 +98,52 @@ class TestCurbCurlMulti < Test::Unit::TestCase
98
98
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, responses[i], "response #{i}")
99
99
  end
100
100
  end
101
-
101
+
102
102
  m = nil
103
103
 
104
104
  end
105
-
105
+
106
106
  def test_idle_check
107
107
  m = Curl::Multi.new
108
108
  e = Curl::Easy.new($TEST_URL)
109
-
109
+
110
110
  assert(m.idle?, 'A new Curl::Multi handle should be idle')
111
-
111
+
112
112
  m.add(e)
113
-
113
+
114
114
  assert((not m.idle?), 'A Curl::Multi handle with a request should not be idle')
115
-
115
+
116
116
  m.perform
117
-
117
+
118
118
  assert(m.idle?, 'A Curl::Multi handle should be idle after performing its requests')
119
119
  end
120
-
120
+
121
121
  def test_requests
122
122
  m = Curl::Multi.new
123
-
123
+
124
124
  assert_equal([], m.requests, 'A new Curl::Multi handle should have no requests')
125
-
125
+
126
126
  10.times do
127
127
  m.add(Curl::Easy.new($TEST_URL))
128
128
  end
129
-
129
+
130
130
  assert_equal(10, m.requests.length, 'multi.requests should contain all the active requests')
131
-
131
+
132
132
  m.perform
133
-
133
+
134
134
  assert_equal([], m.requests, 'A new Curl::Multi handle should have no requests after a perform')
135
135
  end
136
-
136
+
137
137
  def test_cancel
138
138
  m = Curl::Multi.new
139
139
  m.cancel! # shouldn't raise anything
140
-
140
+
141
141
  10.times do
142
142
  m.add(Curl::Easy.new($TEST_URL))
143
143
  end
144
-
144
+
145
145
  m.cancel!
146
-
146
+
147
147
  assert_equal([], m.requests, 'A new Curl::Multi handle should have no requests after being canceled')
148
148
  end
149
149
 
@@ -152,7 +152,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
152
152
  c2 = Curl::Easy.new($TEST_URL)
153
153
  success_called1 = false
154
154
  success_called2 = false
155
-
155
+
156
156
  c1.on_success do|c|
157
157
  success_called1 = true
158
158
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
@@ -175,16 +175,16 @@ class TestCurbCurlMulti < Test::Unit::TestCase
175
175
 
176
176
  assert success_called2
177
177
  assert success_called1
178
-
178
+
179
179
  m = nil
180
180
  end
181
-
181
+
182
182
  def test_with_success_cb_with_404
183
183
  c1 = Curl::Easy.new("#{$TEST_URL.gsub(/file:\/\//,'')}/not_here")
184
184
  c2 = Curl::Easy.new($TEST_URL)
185
185
  success_called1 = false
186
186
  success_called2 = false
187
-
187
+
188
188
  c1.on_success do|c|
189
189
  success_called1 = true
190
190
  #puts "success 1 called: #{c.body_str.inspect}"
@@ -218,7 +218,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
218
218
 
219
219
  assert success_called2
220
220
  assert !success_called1
221
-
221
+
222
222
  m = nil
223
223
  end
224
224
 
@@ -280,7 +280,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
280
280
  curl.on_header{|data| responses["#{url}-header"] << data; data.size }
281
281
  curl.on_body{|data| responses[url] << data; data.size }
282
282
  curl.on_success {
283
- puts curl.last_effective_url
283
+ puts curl.last_effective_url
284
284
  }
285
285
  end
286
286
  m.add(c)
@@ -326,9 +326,9 @@ class TestCurbCurlMulti < Test::Unit::TestCase
326
326
  end
327
327
 
328
328
  def test_multi_easy_put_01
329
- urls = [{ :url => TestServlet.url, :method => :put, :put_data => "message",
329
+ urls = [{ :url => TestServlet.url, :method => :put, :put_data => "message",
330
330
  :headers => {'Content-Type' => 'application/json' } },
331
- { :url => TestServlet.url, :method => :put, :put_data => "message",
331
+ { :url => TestServlet.url, :method => :put, :put_data => "message",
332
332
  :headers => {'Content-Type' => 'application/json' } }]
333
333
  Curl::Multi.put(urls, {}, {:pipeline => true}) do|easy|
334
334
  assert_match /PUT/, easy.body_str
@@ -341,7 +341,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
341
341
  { :url => TestServlet.url + '?q=1', :method => :post, :post_fields => {'field1' => 'value1', 'k' => 'j'}},
342
342
  { :url => TestServlet.url + '?q=2', :method => :post, :post_fields => {'field2' => 'value2', 'foo' => 'bar', 'i' => 'j' }},
343
343
  { :url => TestServlet.url + '?q=3', :method => :post, :post_fields => {'field3' => 'value3', 'field4' => 'value4'}},
344
- { :url => TestServlet.url, :method => :put, :put_data => "message",
344
+ { :url => TestServlet.url, :method => :put, :put_data => "message",
345
345
  :headers => {'Content-Type' => 'application/json' } },
346
346
  { :url => TestServlet.url, :method => :get }
347
347
  ]
@@ -412,7 +412,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
412
412
  assert_equal 0, tries
413
413
  end
414
414
 
415
- include TestServerMethods
415
+ include TestServerMethods
416
416
 
417
417
  def setup
418
418
  server_setup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7.0
4
+ version: 0.5.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Bamford