curb 0.1.4 → 0.7.15
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 +131 -60
- data/Rakefile +81 -68
- data/doc.rb +1 -1
- data/ext/curb.c +107 -70
- data/ext/curb.h +23 -10
- data/ext/curb_easy.c +2156 -908
- data/ext/curb_easy.h +41 -28
- data/ext/curb_errors.c +258 -92
- data/ext/curb_errors.h +25 -2
- data/ext/curb_macros.h +41 -0
- data/ext/curb_multi.c +565 -0
- data/ext/curb_multi.h +26 -0
- data/ext/curb_postfield.c +68 -44
- data/ext/curb_upload.c +80 -0
- data/ext/curb_upload.h +30 -0
- data/ext/extconf.rb +159 -7
- data/lib/curb.rb +308 -0
- data/{ext → lib}/curl.rb +0 -1
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +52 -0
- data/tests/bug_curb_easy_post_with_string_no_content_length_header.rb +83 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +1 -1
- data/tests/bug_multi_segfault.rb +14 -0
- data/tests/bug_postfields_crash.rb +26 -0
- data/tests/bug_postfields_crash2.rb +57 -0
- data/tests/bugtests.rb +9 -0
- data/tests/helper.rb +168 -0
- data/tests/mem_check.rb +65 -0
- data/tests/require_last_or_segfault_script.rb +2 -2
- data/tests/tc_curl_download.rb +75 -0
- data/tests/tc_curl_easy.rb +464 -9
- data/tests/tc_curl_multi.rb +466 -0
- data/tests/tc_curl_postfield.rb +4 -2
- data/tests/timeout.rb +100 -0
- data/tests/timeout_server.rb +33 -0
- metadata +103 -56
- data/ext/curb.rb +0 -46
- data/samples/gmail.rb +0 -48
metadata
CHANGED
|
@@ -1,80 +1,127 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
rubygems_version: 0.9.0
|
|
3
|
-
specification_version: 1
|
|
4
2
|
name: curb
|
|
5
3
|
version: !ruby/object:Gem::Version
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
rubyforge_project: curb
|
|
14
|
-
description: C-language Ruby bindings for the libcurl(3) URL transfer library.
|
|
15
|
-
autorequire:
|
|
16
|
-
default_executable:
|
|
17
|
-
bindir: bin
|
|
18
|
-
has_rdoc: true
|
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
20
|
-
requirements:
|
|
21
|
-
- - ">"
|
|
22
|
-
- !ruby/object:Gem::Version
|
|
23
|
-
version: 0.0.0
|
|
24
|
-
version:
|
|
4
|
+
hash: 29
|
|
5
|
+
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 7
|
|
9
|
+
- 15
|
|
10
|
+
version: 0.7.15
|
|
25
11
|
platform: ruby
|
|
26
|
-
signing_key:
|
|
27
|
-
cert_chain:
|
|
28
|
-
post_install_message:
|
|
29
12
|
authors:
|
|
30
13
|
- Ross Bamford
|
|
14
|
+
- Todd A. Fisher
|
|
15
|
+
autorequire:
|
|
16
|
+
bindir: bin
|
|
17
|
+
cert_chain: []
|
|
18
|
+
|
|
19
|
+
date: 2011-03-20 00:00:00 -04:00
|
|
20
|
+
default_executable:
|
|
21
|
+
dependencies: []
|
|
22
|
+
|
|
23
|
+
description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the libcurl(3), a fully-featured client-side URL transfer library. cURL and libcurl live at http://curl.haxx.se/
|
|
24
|
+
email: todd.fisher@gmail.com
|
|
25
|
+
executables: []
|
|
26
|
+
|
|
27
|
+
extensions:
|
|
28
|
+
- ext/extconf.rb
|
|
29
|
+
extra_rdoc_files:
|
|
30
|
+
- LICENSE
|
|
31
|
+
- README
|
|
31
32
|
files:
|
|
32
|
-
-
|
|
33
|
+
- LICENSE
|
|
34
|
+
- README
|
|
35
|
+
- Rakefile
|
|
36
|
+
- doc.rb
|
|
33
37
|
- ext/extconf.rb
|
|
34
|
-
-
|
|
38
|
+
- lib/curb.rb
|
|
39
|
+
- lib/curl.rb
|
|
35
40
|
- ext/curb.c
|
|
36
41
|
- ext/curb_easy.c
|
|
37
42
|
- ext/curb_errors.c
|
|
43
|
+
- ext/curb_multi.c
|
|
38
44
|
- ext/curb_postfield.c
|
|
39
|
-
- ext/
|
|
40
|
-
- ext/curb_postfield.h
|
|
45
|
+
- ext/curb_upload.c
|
|
41
46
|
- ext/curb.h
|
|
42
|
-
- ext/curb_errors.h
|
|
43
47
|
- ext/curb_easy.h
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
48
|
+
- ext/curb_errors.h
|
|
49
|
+
- ext/curb_macros.h
|
|
50
|
+
- ext/curb_multi.h
|
|
51
|
+
- ext/curb_postfield.h
|
|
52
|
+
- ext/curb_upload.h
|
|
47
53
|
- tests/alltests.rb
|
|
54
|
+
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
|
55
|
+
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
48
56
|
- tests/bug_instance_post_differs_from_class_post.rb
|
|
49
|
-
- tests/
|
|
50
|
-
- tests/
|
|
57
|
+
- tests/bug_multi_segfault.rb
|
|
58
|
+
- tests/bug_postfields_crash.rb
|
|
59
|
+
- tests/bug_postfields_crash2.rb
|
|
60
|
+
- tests/bug_require_last_or_segfault.rb
|
|
61
|
+
- tests/bugtests.rb
|
|
62
|
+
- tests/helper.rb
|
|
63
|
+
- tests/mem_check.rb
|
|
51
64
|
- tests/require_last_or_segfault_script.rb
|
|
52
|
-
-
|
|
53
|
-
- doc.rb
|
|
54
|
-
- Rakefile
|
|
55
|
-
- README
|
|
56
|
-
- LICENSE
|
|
57
|
-
test_files:
|
|
65
|
+
- tests/tc_curl_download.rb
|
|
58
66
|
- tests/tc_curl_easy.rb
|
|
67
|
+
- tests/tc_curl_multi.rb
|
|
59
68
|
- tests/tc_curl_postfield.rb
|
|
69
|
+
- tests/timeout.rb
|
|
70
|
+
- tests/timeout_server.rb
|
|
71
|
+
- tests/unittests.rb
|
|
72
|
+
has_rdoc: true
|
|
73
|
+
homepage: http://curb.rubyforge.org/
|
|
74
|
+
licenses: []
|
|
75
|
+
|
|
76
|
+
post_install_message:
|
|
60
77
|
rdoc_options:
|
|
61
|
-
- --title
|
|
62
|
-
- Curb API
|
|
63
78
|
- --main
|
|
64
79
|
- README
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
- ext
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
require_paths:
|
|
81
|
+
- lib
|
|
82
|
+
- ext
|
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
+
none: false
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
hash: 3
|
|
89
|
+
segments:
|
|
90
|
+
- 0
|
|
91
|
+
version: "0"
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
none: false
|
|
94
|
+
requirements:
|
|
95
|
+
- - ">="
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
hash: 3
|
|
98
|
+
segments:
|
|
99
|
+
- 0
|
|
100
|
+
version: "0"
|
|
77
101
|
requirements: []
|
|
78
102
|
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
rubyforge_project: curb
|
|
104
|
+
rubygems_version: 1.4.1
|
|
105
|
+
signing_key:
|
|
106
|
+
specification_version: 3
|
|
107
|
+
summary: Ruby libcurl bindings
|
|
108
|
+
test_files:
|
|
109
|
+
- tests/alltests.rb
|
|
110
|
+
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
|
111
|
+
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
112
|
+
- tests/bug_instance_post_differs_from_class_post.rb
|
|
113
|
+
- tests/bug_multi_segfault.rb
|
|
114
|
+
- tests/bug_postfields_crash.rb
|
|
115
|
+
- tests/bug_postfields_crash2.rb
|
|
116
|
+
- tests/bug_require_last_or_segfault.rb
|
|
117
|
+
- tests/bugtests.rb
|
|
118
|
+
- tests/helper.rb
|
|
119
|
+
- tests/mem_check.rb
|
|
120
|
+
- tests/require_last_or_segfault_script.rb
|
|
121
|
+
- tests/tc_curl_download.rb
|
|
122
|
+
- tests/tc_curl_easy.rb
|
|
123
|
+
- tests/tc_curl_multi.rb
|
|
124
|
+
- tests/tc_curl_postfield.rb
|
|
125
|
+
- tests/timeout.rb
|
|
126
|
+
- tests/timeout_server.rb
|
|
127
|
+
- tests/unittests.rb
|
data/ext/curb.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'curb_core'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
$: << File.dirname(__FILE__)
|
|
5
|
-
require 'curb_core'
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
module Curl
|
|
9
|
-
class Easy
|
|
10
|
-
class << self
|
|
11
|
-
|
|
12
|
-
# call-seq:
|
|
13
|
-
# Curl::Easy.download(url, filename = url.split(/\?/).first.split(/\//).last) { |curl| ... }
|
|
14
|
-
#
|
|
15
|
-
# Stream the specified url (via perform) and save the data directly to the
|
|
16
|
-
# supplied filename (defaults to the last component of the URL path, which will
|
|
17
|
-
# usually be the filename most simple urls).
|
|
18
|
-
#
|
|
19
|
-
# If a block is supplied, it will be passed the curl instance prior to the
|
|
20
|
-
# perform call.
|
|
21
|
-
#
|
|
22
|
-
# *Note* that the semantics of the on_body handler are subtly changed when using
|
|
23
|
-
# download, to account for the automatic routing of data to the specified file: The
|
|
24
|
-
# data string is passed to the handler *before* it is written
|
|
25
|
-
# to the file, allowing the handler to perform mutative operations where
|
|
26
|
-
# necessary. As usual, the transfer will be aborted if the on_body handler
|
|
27
|
-
# returns a size that differs from the data chunk size - in this case, the
|
|
28
|
-
# offending chunk will *not* be written to the file, the file will be closed,
|
|
29
|
-
# and a Curl::Err::AbortedByCallbackError will be raised.
|
|
30
|
-
def download(url, filename = url.split(/\?/).first.split(/\//).last, &blk)
|
|
31
|
-
curl = Curl::Easy.new(url, &blk)
|
|
32
|
-
|
|
33
|
-
File.open(filename, "wb") do |output|
|
|
34
|
-
old_on_body = curl.on_body do |data|
|
|
35
|
-
result = old_on_body ? old_on_body.call(data) : data.length
|
|
36
|
-
output << data if result == data.length
|
|
37
|
-
result
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
curl.perform
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
data/samples/gmail.rb
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# This logs into gmail, up to the point where it hits the
|
|
2
|
-
# security redirect implemented as a refresh. It will probably
|
|
3
|
-
# stop working altogether when they next change gmail but
|
|
4
|
-
# it's still an example of posting with curb...
|
|
5
|
-
|
|
6
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'ext'))
|
|
7
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
8
|
-
require 'curb'
|
|
9
|
-
|
|
10
|
-
$EMAIL = '<YOUR GMAIL LOGIN>'
|
|
11
|
-
$PASSWD = '<YOUR GMAIL PASSWORD>'
|
|
12
|
-
|
|
13
|
-
url = 'https://www.google.com/accounts/ServiceLoginAuth'
|
|
14
|
-
|
|
15
|
-
fields = [
|
|
16
|
-
Curl::PostField.content('ltmpl','m_blanco'),
|
|
17
|
-
Curl::PostField.content('ltmplcache', '2'),
|
|
18
|
-
Curl::PostField.content('continue',
|
|
19
|
-
'http://mail.google.com/mail/?ui.html&zy=l'),
|
|
20
|
-
Curl::PostField.content('service', 'mail'),
|
|
21
|
-
Curl::PostField.content('rm', 'false'),
|
|
22
|
-
Curl::PostField.content('rmShown', '1'),
|
|
23
|
-
Curl::PostField.content('PersistentCookie', ''),
|
|
24
|
-
Curl::PostField.content('Email', $EMAIL),
|
|
25
|
-
Curl::PostField.content('Passwd', $PASSWD)
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
c = Curl::Easy.http_post(url, *fields) do |curl|
|
|
29
|
-
# Gotta put yourself out there...
|
|
30
|
-
curl.headers["User-Agent"] = "Curl/Ruby"
|
|
31
|
-
|
|
32
|
-
# Let's see what happens under the hood
|
|
33
|
-
curl.verbose = true
|
|
34
|
-
|
|
35
|
-
# Google will redirect us a bit
|
|
36
|
-
curl.follow_location = true
|
|
37
|
-
|
|
38
|
-
# Google will make sure we retain cookies
|
|
39
|
-
curl.enable_cookies = true
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
puts "FINISHED: HTTP #{c.response_code}"
|
|
43
|
-
puts c.body_str
|
|
44
|
-
|
|
45
|
-
# As an alternative to passing the PostFields, we could have supplied
|
|
46
|
-
# individual pre-encoded option strings, or a single string with the
|
|
47
|
-
# entire form data.
|
|
48
|
-
|