curb 0.7.15 → 1.0.0
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.
- checksums.yaml +7 -0
- data/README.markdown +283 -0
- data/Rakefile +38 -26
- data/ext/banned.h +32 -0
- data/ext/curb.c +903 -46
- data/ext/curb.h +20 -11
- data/ext/curb_easy.c +1039 -565
- data/ext/curb_easy.h +12 -0
- data/ext/curb_errors.c +127 -18
- data/ext/curb_errors.h +8 -5
- data/ext/curb_macros.h +10 -6
- data/ext/curb_multi.c +245 -167
- data/ext/curb_multi.h +0 -1
- data/ext/curb_upload.c +2 -2
- data/ext/extconf.rb +314 -20
- data/lib/curb.rb +2 -308
- data/lib/curl/easy.rb +489 -0
- data/lib/curl/multi.rb +287 -0
- data/lib/curl.rb +68 -1
- data/tests/bug_crash_on_debug.rb +39 -0
- data/tests/bug_crash_on_progress.rb +73 -0
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +2 -2
- data/tests/bug_issue102.rb +17 -0
- data/tests/bug_require_last_or_segfault.rb +1 -1
- data/tests/helper.rb +120 -16
- data/tests/signals.rb +33 -0
- data/tests/tc_curl.rb +69 -0
- data/tests/tc_curl_download.rb +4 -4
- data/tests/tc_curl_easy.rb +327 -43
- data/tests/tc_curl_easy_resolve.rb +16 -0
- data/tests/tc_curl_easy_setopt.rb +31 -0
- data/tests/tc_curl_maxfilesize.rb +12 -0
- data/tests/tc_curl_multi.rb +141 -15
- data/tests/tc_curl_postfield.rb +29 -29
- data/tests/tc_curl_protocols.rb +37 -0
- data/tests/timeout.rb +30 -6
- metadata +61 -58
- data/README +0 -177
metadata
CHANGED
|
@@ -1,59 +1,57 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: curb
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 7
|
|
9
|
-
- 15
|
|
10
|
-
version: 0.7.15
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
11
5
|
platform: ruby
|
|
12
|
-
authors:
|
|
6
|
+
authors:
|
|
13
7
|
- Ross Bamford
|
|
14
8
|
- Todd A. Fisher
|
|
15
9
|
autorequire:
|
|
16
10
|
bindir: bin
|
|
17
11
|
cert_chain: []
|
|
18
|
-
|
|
19
|
-
date: 2011-03-20 00:00:00 -04:00
|
|
20
|
-
default_executable:
|
|
12
|
+
date: 2022-01-14 00:00:00.000000000 Z
|
|
21
13
|
dependencies: []
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings
|
|
15
|
+
for the libcurl(3), a fully-featured client-side URL transfer library. cURL and
|
|
16
|
+
libcurl live at http://curl.haxx.se/
|
|
24
17
|
email: todd.fisher@gmail.com
|
|
25
18
|
executables: []
|
|
26
|
-
|
|
27
|
-
extensions:
|
|
19
|
+
extensions:
|
|
28
20
|
- ext/extconf.rb
|
|
29
|
-
extra_rdoc_files:
|
|
21
|
+
extra_rdoc_files:
|
|
30
22
|
- LICENSE
|
|
31
|
-
- README
|
|
32
|
-
files:
|
|
23
|
+
- README.markdown
|
|
24
|
+
files:
|
|
33
25
|
- LICENSE
|
|
34
|
-
- README
|
|
26
|
+
- README.markdown
|
|
35
27
|
- Rakefile
|
|
36
28
|
- doc.rb
|
|
37
|
-
- ext/
|
|
38
|
-
- lib/curb.rb
|
|
39
|
-
- lib/curl.rb
|
|
29
|
+
- ext/banned.h
|
|
40
30
|
- ext/curb.c
|
|
41
|
-
- ext/curb_easy.c
|
|
42
|
-
- ext/curb_errors.c
|
|
43
|
-
- ext/curb_multi.c
|
|
44
|
-
- ext/curb_postfield.c
|
|
45
|
-
- ext/curb_upload.c
|
|
46
31
|
- ext/curb.h
|
|
32
|
+
- ext/curb_easy.c
|
|
47
33
|
- ext/curb_easy.h
|
|
34
|
+
- ext/curb_errors.c
|
|
48
35
|
- ext/curb_errors.h
|
|
49
36
|
- ext/curb_macros.h
|
|
37
|
+
- ext/curb_multi.c
|
|
50
38
|
- ext/curb_multi.h
|
|
39
|
+
- ext/curb_postfield.c
|
|
51
40
|
- ext/curb_postfield.h
|
|
41
|
+
- ext/curb_upload.c
|
|
52
42
|
- ext/curb_upload.h
|
|
43
|
+
- ext/extconf.rb
|
|
44
|
+
- lib/curb.rb
|
|
45
|
+
- lib/curl.rb
|
|
46
|
+
- lib/curl/easy.rb
|
|
47
|
+
- lib/curl/multi.rb
|
|
53
48
|
- tests/alltests.rb
|
|
49
|
+
- tests/bug_crash_on_debug.rb
|
|
50
|
+
- tests/bug_crash_on_progress.rb
|
|
54
51
|
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
|
55
52
|
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
56
53
|
- tests/bug_instance_post_differs_from_class_post.rb
|
|
54
|
+
- tests/bug_issue102.rb
|
|
57
55
|
- tests/bug_multi_segfault.rb
|
|
58
56
|
- tests/bug_postfields_crash.rb
|
|
59
57
|
- tests/bug_postfields_crash2.rb
|
|
@@ -62,54 +60,53 @@ files:
|
|
|
62
60
|
- tests/helper.rb
|
|
63
61
|
- tests/mem_check.rb
|
|
64
62
|
- tests/require_last_or_segfault_script.rb
|
|
63
|
+
- tests/signals.rb
|
|
64
|
+
- tests/tc_curl.rb
|
|
65
65
|
- tests/tc_curl_download.rb
|
|
66
66
|
- tests/tc_curl_easy.rb
|
|
67
|
+
- tests/tc_curl_easy_resolve.rb
|
|
68
|
+
- tests/tc_curl_easy_setopt.rb
|
|
69
|
+
- tests/tc_curl_maxfilesize.rb
|
|
67
70
|
- tests/tc_curl_multi.rb
|
|
68
71
|
- tests/tc_curl_postfield.rb
|
|
72
|
+
- tests/tc_curl_protocols.rb
|
|
69
73
|
- tests/timeout.rb
|
|
70
74
|
- tests/timeout_server.rb
|
|
71
75
|
- tests/unittests.rb
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
homepage: https://github.com/taf2/curb
|
|
77
|
+
licenses:
|
|
78
|
+
- MIT
|
|
79
|
+
metadata: {}
|
|
76
80
|
post_install_message:
|
|
77
|
-
rdoc_options:
|
|
78
|
-
- --main
|
|
79
|
-
- README
|
|
80
|
-
require_paths:
|
|
81
|
+
rdoc_options:
|
|
82
|
+
- "--main"
|
|
83
|
+
- README.markdown
|
|
84
|
+
require_paths:
|
|
81
85
|
- lib
|
|
82
86
|
- ext
|
|
83
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
-
|
|
85
|
-
requirements:
|
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
86
89
|
- - ">="
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
version: "0"
|
|
92
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
-
none: false
|
|
94
|
-
requirements:
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
95
94
|
- - ">="
|
|
96
|
-
- !ruby/object:Gem::Version
|
|
97
|
-
|
|
98
|
-
segments:
|
|
99
|
-
- 0
|
|
100
|
-
version: "0"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
101
97
|
requirements: []
|
|
102
|
-
|
|
103
|
-
rubyforge_project: curb
|
|
104
|
-
rubygems_version: 1.4.1
|
|
98
|
+
rubygems_version: 3.3.3
|
|
105
99
|
signing_key:
|
|
106
|
-
specification_version:
|
|
100
|
+
specification_version: 4
|
|
107
101
|
summary: Ruby libcurl bindings
|
|
108
|
-
test_files:
|
|
102
|
+
test_files:
|
|
109
103
|
- tests/alltests.rb
|
|
104
|
+
- tests/bug_crash_on_debug.rb
|
|
105
|
+
- tests/bug_crash_on_progress.rb
|
|
110
106
|
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
|
111
107
|
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
112
108
|
- tests/bug_instance_post_differs_from_class_post.rb
|
|
109
|
+
- tests/bug_issue102.rb
|
|
113
110
|
- tests/bug_multi_segfault.rb
|
|
114
111
|
- tests/bug_postfields_crash.rb
|
|
115
112
|
- tests/bug_postfields_crash2.rb
|
|
@@ -118,10 +115,16 @@ test_files:
|
|
|
118
115
|
- tests/helper.rb
|
|
119
116
|
- tests/mem_check.rb
|
|
120
117
|
- tests/require_last_or_segfault_script.rb
|
|
118
|
+
- tests/signals.rb
|
|
119
|
+
- tests/tc_curl.rb
|
|
121
120
|
- tests/tc_curl_download.rb
|
|
122
121
|
- tests/tc_curl_easy.rb
|
|
122
|
+
- tests/tc_curl_easy_resolve.rb
|
|
123
|
+
- tests/tc_curl_easy_setopt.rb
|
|
124
|
+
- tests/tc_curl_maxfilesize.rb
|
|
123
125
|
- tests/tc_curl_multi.rb
|
|
124
126
|
- tests/tc_curl_postfield.rb
|
|
127
|
+
- tests/tc_curl_protocols.rb
|
|
125
128
|
- tests/timeout.rb
|
|
126
129
|
- tests/timeout_server.rb
|
|
127
130
|
- tests/unittests.rb
|
data/README
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
# Curb - Libcurl bindings for Ruby
|
|
2
|
-
|
|
3
|
-
+ [rubyforge rdoc](http://curb.rubyforge.org/)
|
|
4
|
-
+ [rubyforge project](http://rubyforge.org/projects/curb)
|
|
5
|
-
+ [github project](http://github.com/taf2/curb/tree/master)
|
|
6
|
-
|
|
7
|
-
Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the
|
|
8
|
-
libcurl(3), a fully-featured client-side URL transfer library.
|
|
9
|
-
cURL and libcurl live at [http://curl.haxx.se/](http://curl.haxx.se/) .
|
|
10
|
-
|
|
11
|
-
Curb is a work-in-progress, and currently only supports libcurl's 'easy' and 'multi' modes.
|
|
12
|
-
|
|
13
|
-
## License
|
|
14
|
-
|
|
15
|
-
Curb is copyright (c)2006 Ross Bamford, and released under the terms of the
|
|
16
|
-
Ruby license. See the LICENSE file for the gory details.
|
|
17
|
-
|
|
18
|
-
## You will need
|
|
19
|
-
|
|
20
|
-
+ A working Ruby installation (1.8+, tested with 1.8.6, 1.8.7, 1.9.1, and 1.9.2)
|
|
21
|
-
+ A working (lib)curl installation, with development stuff (7.5+, tested with 7.19.x)
|
|
22
|
-
+ A sane build environment (e.g. gcc, make)
|
|
23
|
-
|
|
24
|
-
## Installation...
|
|
25
|
-
|
|
26
|
-
... will usually be as simple as:
|
|
27
|
-
|
|
28
|
-
$ gem install curb
|
|
29
|
-
|
|
30
|
-
Or, if you downloaded the archive:
|
|
31
|
-
|
|
32
|
-
$ rake install
|
|
33
|
-
|
|
34
|
-
If you have a wierd setup, you might need extconf options. In this case, pass
|
|
35
|
-
them like so:
|
|
36
|
-
|
|
37
|
-
$ rake install EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever'
|
|
38
|
-
|
|
39
|
-
Curb is tested only on GNU/Linux x86 and Mac OSX - YMMV on other platforms.
|
|
40
|
-
If you do use another platform and experience problems, or if you can
|
|
41
|
-
expand on the above instructions, please report the issue at http://github.com/taf2/curb/issues
|
|
42
|
-
|
|
43
|
-
Curb has fairly extensive RDoc comments in the source. You can build the
|
|
44
|
-
documentation with:
|
|
45
|
-
|
|
46
|
-
$ rake doc
|
|
47
|
-
|
|
48
|
-
## Usage & examples
|
|
49
|
-
|
|
50
|
-
Curb provides two classes:
|
|
51
|
-
|
|
52
|
-
+ Curl::Easy - simple API, for day-to-day tasks.
|
|
53
|
-
+ Curl::Multi - more advanced API, for operating on multiple URLs simultaneously.
|
|
54
|
-
|
|
55
|
-
### Simple fetch via HTTP:
|
|
56
|
-
|
|
57
|
-
c = Curl::Easy.perform("http://www.google.co.uk")
|
|
58
|
-
puts c.body_str
|
|
59
|
-
|
|
60
|
-
Same thing, more manual:
|
|
61
|
-
|
|
62
|
-
c = Curl::Easy.new("http://www.google.co.uk")
|
|
63
|
-
c.perform
|
|
64
|
-
puts c.body_str
|
|
65
|
-
|
|
66
|
-
### Additional config:
|
|
67
|
-
|
|
68
|
-
Curl::Easy.perform("http://www.google.co.uk") do |curl|
|
|
69
|
-
curl.headers["User-Agent"] = "myapp-0.0"
|
|
70
|
-
curl.verbose = true
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
Same thing, more manual:
|
|
74
|
-
|
|
75
|
-
c = Curl::Easy.new("http://www.google.co.uk") do |curl|
|
|
76
|
-
curl.headers["User-Agent"] = "myapp-0.0"
|
|
77
|
-
curl.verbose = true
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
c.perform
|
|
81
|
-
|
|
82
|
-
### HTTP basic authentication:
|
|
83
|
-
|
|
84
|
-
c = Curl::Easy.new("http://github.com/")
|
|
85
|
-
c.http_auth_types = :basic
|
|
86
|
-
c.username = 'foo'
|
|
87
|
-
c.password = 'bar'
|
|
88
|
-
c.perform
|
|
89
|
-
|
|
90
|
-
### Supplying custom handlers:
|
|
91
|
-
|
|
92
|
-
c = Curl::Easy.new("http://www.google.co.uk")
|
|
93
|
-
|
|
94
|
-
c.on_body { |data| print(data) }
|
|
95
|
-
c.on_header { |data| print(data) }
|
|
96
|
-
|
|
97
|
-
c.perform
|
|
98
|
-
|
|
99
|
-
### Reusing Curls:
|
|
100
|
-
|
|
101
|
-
c = Curl::Easy.new
|
|
102
|
-
|
|
103
|
-
["http://www.google.co.uk", "http://www.ruby-lang.org/"].map do |url|
|
|
104
|
-
c.url = url
|
|
105
|
-
c.perform
|
|
106
|
-
c.body_str
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
### HTTP POST form:
|
|
110
|
-
|
|
111
|
-
c = Curl::Easy.http_post("http://my.rails.box/thing/create",
|
|
112
|
-
Curl::PostField.content('thing[name]', 'box'),
|
|
113
|
-
Curl::PostField.content('thing[type]', 'storage'))
|
|
114
|
-
|
|
115
|
-
### HTTP POST file upload:
|
|
116
|
-
|
|
117
|
-
c = Curl::Easy.new("http://my.rails.box/files/upload")
|
|
118
|
-
c.multipart_form_post = true
|
|
119
|
-
c.http_post(Curl::PostField.file('myfile.rb'))
|
|
120
|
-
|
|
121
|
-
### Multi Interface (Basic HTTP GET):
|
|
122
|
-
|
|
123
|
-
# make multiple GET requests
|
|
124
|
-
easy_options = {:follow_location => true}
|
|
125
|
-
multi_options = {:pipeline => true}
|
|
126
|
-
|
|
127
|
-
Curl::Multi.get('url1','url2','url3','url4','url5', easy_options, multi_options) do|easy|
|
|
128
|
-
# do something interesting with the easy response
|
|
129
|
-
puts easy.last_effective_url
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
### Multi Interface (Basic HTTP POST):
|
|
133
|
-
|
|
134
|
-
# make multiple POST requests
|
|
135
|
-
easy_options = {:follow_location => true, :multipart_form_post => true}
|
|
136
|
-
multi_options = {:pipeline => true}
|
|
137
|
-
|
|
138
|
-
url_fields = [
|
|
139
|
-
{ :url => 'url1', :post_fields => {'f1' => 'v1'} },
|
|
140
|
-
{ :url => 'url2', :post_fields => {'f1' => 'v1'} },
|
|
141
|
-
{ :url => 'url3', :post_fields => {'f1' => 'v1'} }
|
|
142
|
-
]
|
|
143
|
-
|
|
144
|
-
Curl::Multi.post(url_fields, easy_options, multi_options) do|easy|
|
|
145
|
-
# do something interesting with the easy response
|
|
146
|
-
puts easy.last_effective_url
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
### Multi Interface (Advanced):
|
|
150
|
-
|
|
151
|
-
responses = {}
|
|
152
|
-
requests = ["http://www.google.co.uk/", "http://www.ruby-lang.org/"]
|
|
153
|
-
m = Curl::Multi.new
|
|
154
|
-
# add a few easy handles
|
|
155
|
-
requests.each do |url|
|
|
156
|
-
responses[url] = ""
|
|
157
|
-
c = Curl::Easy.new(url) do|curl|
|
|
158
|
-
curl.follow_location = true
|
|
159
|
-
curl.on_body{|data| responses[url] << data; data.size }
|
|
160
|
-
curl.on_success {|easy| puts "success, add more easy handles" }
|
|
161
|
-
end
|
|
162
|
-
m.add(c)
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
m.perform do
|
|
166
|
-
puts "idling... can do some work here"
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
requests.each do|url|
|
|
170
|
-
puts responses[url]
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
### Easy Callbacks
|
|
174
|
-
|
|
175
|
-
on_success: is called when the response code is 20x
|
|
176
|
-
on_failure: is called when the response code is not success, including redirects e.g. 30x
|
|
177
|
-
on_complete: is called in all cases.
|