curb 0.6.5.0 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +42 -5
- data/Rakefile +27 -4
- data/ext/curb.c +638 -0
- data/ext/curb.h +6 -4
- data/ext/curb_easy.c +954 -573
- data/ext/curb_easy.h +31 -2
- data/ext/curb_errors.c +16 -2
- data/ext/curb_errors.h +1 -0
- data/ext/curb_macros.h +4 -0
- data/ext/curb_multi.c +229 -67
- data/ext/curb_postfield.c +61 -49
- data/ext/curb_upload.c +2 -2
- data/ext/extconf.rb +232 -4
- data/lib/curb.rb +1 -186
- data/lib/curl/easy.rb +468 -0
- data/lib/curl/multi.rb +248 -0
- data/lib/curl.rb +61 -1
- data/tests/bug_crash_on_debug.rb +39 -0
- data/tests/bug_crash_on_progress.rb +33 -0
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +2 -2
- data/tests/bug_issue102.rb +17 -0
- data/tests/bug_multi_segfault.rb +6 -2
- data/tests/bug_postfields_crash2.rb +57 -0
- data/tests/bug_require_last_or_segfault.rb +1 -1
- data/tests/bugtests.rb +9 -0
- data/tests/helper.rb +40 -10
- data/tests/signals.rb +33 -0
- data/tests/tc_curl.rb +39 -0
- data/tests/tc_curl_download.rb +44 -1
- data/tests/tc_curl_easy.rb +355 -22
- data/tests/tc_curl_easy_setopt.rb +31 -0
- data/tests/tc_curl_multi.rb +57 -5
- data/tests/tc_curl_postfield.rb +3 -1
- data/tests/timeout.rb +100 -0
- data/tests/timeout_server.rb +33 -0
- metadata +87 -48
data/tests/timeout.rb
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
|
2
|
+
|
|
3
|
+
# Run server with: ruby -rubygems timeout_server.rb -p 9128
|
|
4
|
+
|
|
5
|
+
# Note that curl requires all timeouts to be integers -
|
|
6
|
+
# curl_easy_setopt does not have a provision for floating-point values
|
|
7
|
+
|
|
8
|
+
class TestCurbTimeouts < Test::Unit::TestCase
|
|
9
|
+
def test_no_timeout_by_default
|
|
10
|
+
curl = Curl::Easy.new(wait_url(2))
|
|
11
|
+
start = Time.now
|
|
12
|
+
assert_equal true, curl.http_get
|
|
13
|
+
elapsed = Time.now - start
|
|
14
|
+
assert elapsed > 2
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_overall_timeout_on_dead_transfer
|
|
18
|
+
curl = Curl::Easy.new(wait_url(2))
|
|
19
|
+
curl.timeout = 1
|
|
20
|
+
assert_raise(Curl::Err::TimeoutError) do
|
|
21
|
+
curl.http_get
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_clearing_timeout
|
|
26
|
+
curl = Curl::Easy.new(wait_url(2))
|
|
27
|
+
curl.timeout = 1
|
|
28
|
+
curl.timeout = nil
|
|
29
|
+
start = Time.now
|
|
30
|
+
assert_equal true, curl.http_get
|
|
31
|
+
elapsed = Time.now - start
|
|
32
|
+
assert elapsed > 2
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_overall_timeout_on_slow_transfer
|
|
36
|
+
curl = Curl::Easy.new(serve_url(100, 2, 3))
|
|
37
|
+
curl.timeout = 1
|
|
38
|
+
# transfer is aborted despite data being exchanged
|
|
39
|
+
assert_raise(Curl::Err::TimeoutError) do
|
|
40
|
+
curl.http_get
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_low_speed_time_on_slow_transfer
|
|
45
|
+
curl = Curl::Easy.new(serve_url(100, 1, 3))
|
|
46
|
+
curl.low_speed_time = 2
|
|
47
|
+
# use default low_speed_limit of 1
|
|
48
|
+
assert true, curl.http_get
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_low_speed_time_on_very_slow_transfer
|
|
52
|
+
# send data slower than required
|
|
53
|
+
curl = Curl::Easy.new(serve_url(10, 2, 3))
|
|
54
|
+
curl.low_speed_time = 1
|
|
55
|
+
# XXX for some reason this test fails if low speed limit is not specified
|
|
56
|
+
curl.low_speed_limit = 1
|
|
57
|
+
# use default low_speed_limit of 1
|
|
58
|
+
assert_raise(Curl::Err::TimeoutError) do
|
|
59
|
+
curl.http_get
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_low_speed_limit_on_slow_transfer
|
|
64
|
+
curl = Curl::Easy.new(serve_url(10, 1, 3))
|
|
65
|
+
curl.low_speed_time = 2
|
|
66
|
+
curl.low_speed_limit = 1000
|
|
67
|
+
assert_raise(Curl::Err::TimeoutError) do
|
|
68
|
+
curl.http_get
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_clearing_low_speed_time
|
|
73
|
+
curl = Curl::Easy.new(serve_url(100, 2, 3))
|
|
74
|
+
curl.low_speed_time = 1
|
|
75
|
+
curl.low_speed_time = nil
|
|
76
|
+
assert_equal true, curl.http_get
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_clearing_low_speed_limit
|
|
80
|
+
curl = Curl::Easy.new(serve_url(10, 1, 3))
|
|
81
|
+
curl.low_speed_time = 2
|
|
82
|
+
curl.low_speed_limit = 1000
|
|
83
|
+
curl.low_speed_limit = nil
|
|
84
|
+
assert_equal true, curl.http_get
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
def wait_url(time)
|
|
90
|
+
"#{server_base}/wait/#{time}"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def serve_url(chunk_size, time, count)
|
|
94
|
+
"#{server_base}/serve/#{chunk_size}/every/#{time}/for/#{count}"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def server_base
|
|
98
|
+
'http://127.0.0.1:9128'
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This Sinatra application must be run with mongrel
|
|
2
|
+
# or possibly with unicorn for the serve action to work properly.
|
|
3
|
+
# See http://efreedom.com/Question/1-3669674/Streaming-Data-Sinatra-Rack-Application
|
|
4
|
+
|
|
5
|
+
require 'sinatra'
|
|
6
|
+
|
|
7
|
+
get '/wait/:time' do |time|
|
|
8
|
+
time = time.to_i
|
|
9
|
+
sleep(time)
|
|
10
|
+
"Slept #{time} at #{Time.now}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# http://efreedom.com/Question/1-3027435/Way-Flush-Html-Wire-Sinatra
|
|
14
|
+
class Streamer
|
|
15
|
+
def initialize(time, chunks)
|
|
16
|
+
@time = time
|
|
17
|
+
@chunks = chunks
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def each
|
|
21
|
+
@chunks.each do |chunk|
|
|
22
|
+
sleep(@time)
|
|
23
|
+
yield chunk
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
get '/serve/:chunk_size/every/:time/for/:count' do |chunk_size, time, count|
|
|
29
|
+
chunk_size, time, count = chunk_size.to_i, time.to_i, count.to_i
|
|
30
|
+
chunk = 'x' * chunk_size
|
|
31
|
+
chunks = [chunk] * count
|
|
32
|
+
Streamer.new(time, chunks)
|
|
33
|
+
end
|
metadata
CHANGED
|
@@ -1,92 +1,131 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: curb
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.8.4
|
|
5
|
+
prerelease:
|
|
5
6
|
platform: ruby
|
|
6
|
-
authors:
|
|
7
|
+
authors:
|
|
7
8
|
- Ross Bamford
|
|
8
9
|
- Todd A. Fisher
|
|
9
10
|
autorequire:
|
|
10
11
|
bindir: bin
|
|
11
12
|
cert_chain: []
|
|
12
|
-
|
|
13
|
-
date: 2010-01-26 00:00:00 -05:00
|
|
14
|
-
default_executable:
|
|
13
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
|
15
14
|
dependencies: []
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings
|
|
16
|
+
for the libcurl(3), a fully-featured client-side URL transfer library. cURL and
|
|
17
|
+
libcurl live at http://curl.haxx.se/
|
|
18
18
|
email: todd.fisher@gmail.com
|
|
19
19
|
executables: []
|
|
20
|
-
|
|
21
|
-
extensions:
|
|
20
|
+
extensions:
|
|
22
21
|
- ext/extconf.rb
|
|
23
|
-
extra_rdoc_files:
|
|
22
|
+
extra_rdoc_files:
|
|
24
23
|
- LICENSE
|
|
25
24
|
- README
|
|
26
|
-
files:
|
|
25
|
+
files:
|
|
27
26
|
- LICENSE
|
|
28
27
|
- README
|
|
29
28
|
- Rakefile
|
|
30
29
|
- doc.rb
|
|
31
30
|
- ext/extconf.rb
|
|
32
|
-
- lib/curl.rb
|
|
33
31
|
- lib/curb.rb
|
|
32
|
+
- lib/curl/easy.rb
|
|
33
|
+
- lib/curl/multi.rb
|
|
34
|
+
- lib/curl.rb
|
|
34
35
|
- ext/curb.c
|
|
35
|
-
- ext/curb_upload.c
|
|
36
|
-
- ext/curb_postfield.c
|
|
37
36
|
- ext/curb_easy.c
|
|
38
|
-
- ext/curb_multi.c
|
|
39
37
|
- ext/curb_errors.c
|
|
40
|
-
- ext/
|
|
41
|
-
- ext/
|
|
38
|
+
- ext/curb_multi.c
|
|
39
|
+
- ext/curb_postfield.c
|
|
40
|
+
- ext/curb_upload.c
|
|
42
41
|
- ext/curb.h
|
|
43
42
|
- ext/curb_easy.h
|
|
43
|
+
- ext/curb_errors.h
|
|
44
|
+
- ext/curb_macros.h
|
|
45
|
+
- ext/curb_multi.h
|
|
44
46
|
- ext/curb_postfield.h
|
|
45
47
|
- ext/curb_upload.h
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
+
- tests/alltests.rb
|
|
49
|
+
- tests/bug_crash_on_debug.rb
|
|
50
|
+
- tests/bug_crash_on_progress.rb
|
|
51
|
+
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
|
52
|
+
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
53
|
+
- tests/bug_instance_post_differs_from_class_post.rb
|
|
54
|
+
- tests/bug_issue102.rb
|
|
55
|
+
- tests/bug_multi_segfault.rb
|
|
56
|
+
- tests/bug_postfields_crash.rb
|
|
57
|
+
- tests/bug_postfields_crash2.rb
|
|
58
|
+
- tests/bug_require_last_or_segfault.rb
|
|
59
|
+
- tests/bugtests.rb
|
|
60
|
+
- tests/helper.rb
|
|
61
|
+
- tests/mem_check.rb
|
|
62
|
+
- tests/require_last_or_segfault_script.rb
|
|
63
|
+
- tests/signals.rb
|
|
64
|
+
- tests/tc_curl.rb
|
|
65
|
+
- tests/tc_curl_download.rb
|
|
66
|
+
- tests/tc_curl_easy.rb
|
|
67
|
+
- tests/tc_curl_easy_setopt.rb
|
|
68
|
+
- tests/tc_curl_multi.rb
|
|
69
|
+
- tests/tc_curl_postfield.rb
|
|
70
|
+
- tests/timeout.rb
|
|
71
|
+
- tests/timeout_server.rb
|
|
72
|
+
- tests/unittests.rb
|
|
48
73
|
homepage: http://curb.rubyforge.org/
|
|
49
74
|
licenses: []
|
|
50
|
-
|
|
51
75
|
post_install_message:
|
|
52
|
-
rdoc_options:
|
|
76
|
+
rdoc_options:
|
|
53
77
|
- --main
|
|
54
78
|
- README
|
|
55
|
-
require_paths:
|
|
79
|
+
require_paths:
|
|
56
80
|
- lib
|
|
57
81
|
- ext
|
|
58
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
|
+
none: false
|
|
84
|
+
requirements:
|
|
85
|
+
- - ! '>='
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
segments:
|
|
89
|
+
- 0
|
|
90
|
+
hash: -243569426931689339
|
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
|
+
none: false
|
|
93
|
+
requirements:
|
|
94
|
+
- - ! '>='
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
segments:
|
|
98
|
+
- 0
|
|
99
|
+
hash: -243569426931689339
|
|
70
100
|
requirements: []
|
|
71
|
-
|
|
72
101
|
rubyforge_project: curb
|
|
73
|
-
rubygems_version: 1.
|
|
102
|
+
rubygems_version: 1.8.24
|
|
74
103
|
signing_key:
|
|
75
104
|
specification_version: 3
|
|
76
105
|
summary: Ruby libcurl bindings
|
|
77
|
-
test_files:
|
|
78
|
-
- tests/
|
|
79
|
-
- tests/
|
|
80
|
-
- tests/
|
|
81
|
-
- tests/
|
|
106
|
+
test_files:
|
|
107
|
+
- tests/alltests.rb
|
|
108
|
+
- tests/bug_crash_on_debug.rb
|
|
109
|
+
- tests/bug_crash_on_progress.rb
|
|
110
|
+
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
|
111
|
+
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
82
112
|
- tests/bug_instance_post_differs_from_class_post.rb
|
|
113
|
+
- tests/bug_issue102.rb
|
|
83
114
|
- tests/bug_multi_segfault.rb
|
|
84
|
-
- tests/alltests.rb
|
|
85
115
|
- tests/bug_postfields_crash.rb
|
|
116
|
+
- tests/bug_postfields_crash2.rb
|
|
117
|
+
- tests/bug_require_last_or_segfault.rb
|
|
118
|
+
- tests/bugtests.rb
|
|
119
|
+
- tests/helper.rb
|
|
120
|
+
- tests/mem_check.rb
|
|
86
121
|
- tests/require_last_or_segfault_script.rb
|
|
87
|
-
- tests/
|
|
88
|
-
- tests/
|
|
89
|
-
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
122
|
+
- tests/signals.rb
|
|
123
|
+
- tests/tc_curl.rb
|
|
90
124
|
- tests/tc_curl_download.rb
|
|
91
125
|
- tests/tc_curl_easy.rb
|
|
92
|
-
- tests/
|
|
126
|
+
- tests/tc_curl_easy_setopt.rb
|
|
127
|
+
- tests/tc_curl_multi.rb
|
|
128
|
+
- tests/tc_curl_postfield.rb
|
|
129
|
+
- tests/timeout.rb
|
|
130
|
+
- tests/timeout_server.rb
|
|
131
|
+
- tests/unittests.rb
|