curb 0.8.5 → 0.8.8
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 +240 -0
- data/Rakefile +2 -7
- data/ext/curb.c +7 -0
- data/ext/curb.h +5 -9
- data/ext/curb_easy.c +48 -7
- data/ext/curb_errors.c +27 -16
- data/ext/curb_errors.h +8 -5
- data/ext/curb_multi.c +18 -10
- data/ext/extconf.rb +4 -17
- data/lib/curl/easy.rb +69 -59
- data/lib/curl.rb +6 -1
- data/tests/bug_crash_on_progress.rb +41 -1
- data/tests/bug_issue102.rb +17 -0
- data/tests/helper.rb +6 -1
- data/tests/tc_curl_download.rb +1 -1
- data/tests/tc_curl_easy.rb +17 -4
- data/tests/tc_curl_multi.rb +1 -1
- metadata +23 -24
- data/README +0 -194
data/ext/extconf.rb
CHANGED
|
@@ -80,6 +80,7 @@ have_constant "curl_version_sspi"
|
|
|
80
80
|
have_constant "curl_version_conv"
|
|
81
81
|
have_constant "curlproxy_http"
|
|
82
82
|
have_constant "curlproxy_socks4"
|
|
83
|
+
have_constant "curlproxy_socks4a"
|
|
83
84
|
have_constant "curlproxy_socks5"
|
|
84
85
|
have_constant "curlauth_basic"
|
|
85
86
|
have_constant "curlauth_digest"
|
|
@@ -357,6 +358,8 @@ have_constant "curlopt_gssapi_delegation"
|
|
|
357
358
|
have_constant "curlgssapi_delegation_policy_flag"
|
|
358
359
|
have_constant "curlgssapi_delegation_flag"
|
|
359
360
|
|
|
361
|
+
have_constant "CURLM_ADDED_ALREADY"
|
|
362
|
+
|
|
360
363
|
if try_compile('int main() { return 0; }','-Wall')
|
|
361
364
|
$CFLAGS << ' -Wall'
|
|
362
365
|
end
|
|
@@ -372,23 +375,6 @@ def test_for(name, const, src)
|
|
|
372
375
|
end
|
|
373
376
|
end
|
|
374
377
|
end
|
|
375
|
-
test_for("Ruby 1.9 Hash", "RUBY19_HASH", %{
|
|
376
|
-
#include <ruby.h>
|
|
377
|
-
int main() {
|
|
378
|
-
VALUE hash = rb_hash_new();
|
|
379
|
-
if( RHASH(hash)->ntbl->num_entries ) {
|
|
380
|
-
return 0;
|
|
381
|
-
}
|
|
382
|
-
return 1;
|
|
383
|
-
}
|
|
384
|
-
})
|
|
385
|
-
test_for("Ruby 1.9 st.h", "RUBY19_ST_H", %{
|
|
386
|
-
#include <ruby.h>
|
|
387
|
-
#include <ruby/st.h>
|
|
388
|
-
int main() {
|
|
389
|
-
return 0;
|
|
390
|
-
}
|
|
391
|
-
})
|
|
392
378
|
|
|
393
379
|
test_for("curl_easy_escape", "CURL_EASY_ESCAPE", %{
|
|
394
380
|
#include <curl/curl.h>
|
|
@@ -400,6 +386,7 @@ test_for("curl_easy_escape", "CURL_EASY_ESCAPE", %{
|
|
|
400
386
|
})
|
|
401
387
|
|
|
402
388
|
have_func('rb_thread_blocking_region')
|
|
389
|
+
have_header('ruby/thread.h') && have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
|
|
403
390
|
|
|
404
391
|
create_header('curb_config.h')
|
|
405
392
|
create_makefile('curb_core')
|
data/lib/curl/easy.rb
CHANGED
|
@@ -6,31 +6,41 @@ module Curl
|
|
|
6
6
|
alias body body_str
|
|
7
7
|
alias head header_str
|
|
8
8
|
|
|
9
|
+
class Error < Exception
|
|
10
|
+
attr_accessor :message, :code
|
|
11
|
+
def initialize(code, msg)
|
|
12
|
+
self.message = msg
|
|
13
|
+
self.code = code
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
9
17
|
#
|
|
10
18
|
# call-seq:
|
|
11
19
|
# easy.status => String
|
|
12
20
|
#
|
|
13
21
|
def status
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
while parts.size > 0 && parts.first != ''
|
|
18
|
-
status << parts.shift
|
|
19
|
-
end
|
|
20
|
-
status.join(' ')
|
|
22
|
+
# Matches the last HTTP Status - following the HTTP protocol specification 'Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF'
|
|
23
|
+
statuses = self.header_str.scan(/HTTP\/\d\.\d\s(\d+\s.+)\r\n/).map{ |match| match[0] }
|
|
24
|
+
statuses.last.strip
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
#
|
|
24
28
|
# call-seq:
|
|
25
29
|
# easy.set :sym|Fixnum, value
|
|
26
|
-
#
|
|
30
|
+
#
|
|
27
31
|
# set options on the curl easy handle see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
|
|
28
32
|
#
|
|
29
33
|
def set(opt,val)
|
|
30
34
|
if opt.is_a?(Symbol)
|
|
31
|
-
|
|
35
|
+
option = sym2curl(opt)
|
|
32
36
|
else
|
|
33
|
-
|
|
37
|
+
option = opt.to_i
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
begin
|
|
41
|
+
setopt(option, val)
|
|
42
|
+
rescue TypeError
|
|
43
|
+
raise TypeError, "Curb doesn't support setting #{opt} [##{option}] option"
|
|
34
44
|
end
|
|
35
45
|
end
|
|
36
46
|
|
|
@@ -58,8 +68,8 @@ module Curl
|
|
|
58
68
|
ret = self.multi.perform
|
|
59
69
|
|
|
60
70
|
if self.last_result != 0 && self.on_failure.nil?
|
|
61
|
-
error = Curl::Easy.error(self.last_result)
|
|
62
|
-
raise error.first
|
|
71
|
+
error = Curl::Easy.error(self.last_result)
|
|
72
|
+
raise error.first.new(error.last)
|
|
63
73
|
end
|
|
64
74
|
|
|
65
75
|
ret
|
|
@@ -83,54 +93,54 @@ module Curl
|
|
|
83
93
|
# easy.perform
|
|
84
94
|
#
|
|
85
95
|
def delete=(onoff)
|
|
86
|
-
set :customrequest, onoff ? '
|
|
96
|
+
set :customrequest, onoff ? 'DELETE' : nil
|
|
87
97
|
onoff
|
|
88
98
|
end
|
|
89
|
-
#
|
|
99
|
+
#
|
|
90
100
|
# call-seq:
|
|
91
|
-
#
|
|
101
|
+
#
|
|
92
102
|
# easy = Curl::Easy.new("url")
|
|
93
103
|
# easy.version = Curl::HTTP_1_1
|
|
94
104
|
# easy.version = Curl::HTTP_1_0
|
|
95
105
|
# easy.version = Curl::HTTP_NONE
|
|
96
|
-
#
|
|
106
|
+
#
|
|
97
107
|
def version=(http_version)
|
|
98
108
|
set :http_version, http_version
|
|
99
109
|
end
|
|
100
110
|
|
|
101
|
-
#
|
|
111
|
+
#
|
|
102
112
|
# call-seq:
|
|
103
113
|
# easy.url = "http://some.url/" => "http://some.url/"
|
|
104
|
-
#
|
|
114
|
+
#
|
|
105
115
|
# Set the URL for subsequent calls to +perform+. It is acceptable
|
|
106
116
|
# (and even recommended) to reuse Curl::Easy instances by reassigning
|
|
107
117
|
# the URL between calls to +perform+.
|
|
108
|
-
#
|
|
118
|
+
#
|
|
109
119
|
def url=(u)
|
|
110
120
|
set :url, u
|
|
111
121
|
end
|
|
112
122
|
|
|
113
|
-
#
|
|
123
|
+
#
|
|
114
124
|
# call-seq:
|
|
115
125
|
# easy.proxy_url = string => string
|
|
116
|
-
#
|
|
126
|
+
#
|
|
117
127
|
# Set the URL of the HTTP proxy to use for subsequent calls to +perform+.
|
|
118
128
|
# The URL should specify the the host name or dotted IP address. To specify
|
|
119
129
|
# port number in this string, append :[port] to the end of the host name.
|
|
120
130
|
# The proxy string may be prefixed with [protocol]:// since any such prefix
|
|
121
131
|
# will be ignored. The proxy's port number may optionally be specified with
|
|
122
132
|
# the separate option proxy_port .
|
|
123
|
-
#
|
|
133
|
+
#
|
|
124
134
|
# When you tell the library to use an HTTP proxy, libcurl will transparently
|
|
125
135
|
# convert operations to HTTP even if you specify an FTP URL etc. This may have
|
|
126
136
|
# an impact on what other features of the library you can use, such as
|
|
127
137
|
# FTP specifics that don't work unless you tunnel through the HTTP proxy. Such
|
|
128
138
|
# tunneling is activated with proxy_tunnel = true.
|
|
129
|
-
#
|
|
139
|
+
#
|
|
130
140
|
# libcurl respects the environment variables *http_proxy*, *ftp_proxy*,
|
|
131
141
|
# *all_proxy* etc, if any of those is set. The proxy_url option does however
|
|
132
142
|
# override any possibly set environment variables.
|
|
133
|
-
#
|
|
143
|
+
#
|
|
134
144
|
# Starting with libcurl 7.14.1, the proxy host string given in environment
|
|
135
145
|
# variables can be specified the exact same way as the proxy can be set with
|
|
136
146
|
# proxy_url, including protocol prefix (http://) and embedded user + password.
|
|
@@ -145,89 +155,89 @@ module Curl
|
|
|
145
155
|
self.ssl_verify_host_integer=value
|
|
146
156
|
end
|
|
147
157
|
|
|
148
|
-
#
|
|
158
|
+
#
|
|
149
159
|
# call-seq:
|
|
150
160
|
# easy.ssl_verify_host? => boolean
|
|
151
|
-
#
|
|
161
|
+
#
|
|
152
162
|
# Deprecated: call easy.ssl_verify_host instead
|
|
153
163
|
# can be one of [0,1,2]
|
|
154
|
-
#
|
|
164
|
+
#
|
|
155
165
|
# Determine whether this Curl instance will verify that the server cert
|
|
156
166
|
# is for the server it is known as.
|
|
157
|
-
#
|
|
167
|
+
#
|
|
158
168
|
def ssl_verify_host?
|
|
159
169
|
ssl_verify_host.nil? ? false : (ssl_verify_host > 0)
|
|
160
170
|
end
|
|
161
171
|
|
|
162
|
-
#
|
|
172
|
+
#
|
|
163
173
|
# call-seq:
|
|
164
174
|
# easy.interface = string => string
|
|
165
|
-
#
|
|
175
|
+
#
|
|
166
176
|
# Set the interface name to use as the outgoing network interface.
|
|
167
177
|
# The name can be an interface name, an IP address or a host name.
|
|
168
|
-
#
|
|
178
|
+
#
|
|
169
179
|
def interface=(value)
|
|
170
180
|
set :interface, value
|
|
171
181
|
end
|
|
172
182
|
|
|
173
|
-
#
|
|
183
|
+
#
|
|
174
184
|
# call-seq:
|
|
175
185
|
# easy.userpwd = string => string
|
|
176
|
-
#
|
|
186
|
+
#
|
|
177
187
|
# Set the username/password string to use for subsequent calls to +perform+.
|
|
178
188
|
# The supplied string should have the form "username:password"
|
|
179
|
-
#
|
|
189
|
+
#
|
|
180
190
|
def userpwd=(value)
|
|
181
191
|
set :userpwd, value
|
|
182
192
|
end
|
|
183
193
|
|
|
184
|
-
#
|
|
194
|
+
#
|
|
185
195
|
# call-seq:
|
|
186
196
|
# easy.proxypwd = string => string
|
|
187
|
-
#
|
|
197
|
+
#
|
|
188
198
|
# Set the username/password string to use for proxy connection during
|
|
189
199
|
# subsequent calls to +perform+. The supplied string should have the
|
|
190
200
|
# form "username:password"
|
|
191
|
-
#
|
|
201
|
+
#
|
|
192
202
|
def proxypwd=(value)
|
|
193
203
|
set :proxyuserpwd, value
|
|
194
204
|
end
|
|
195
205
|
|
|
196
|
-
#
|
|
206
|
+
#
|
|
197
207
|
# call-seq:
|
|
198
208
|
# easy.cookies = "name1=content1; name2=content2;" => string
|
|
199
|
-
#
|
|
209
|
+
#
|
|
200
210
|
# Set cookies to be sent by this Curl::Easy instance. The format of the string should
|
|
201
211
|
# be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
|
|
202
212
|
# Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
|
|
203
|
-
#
|
|
213
|
+
#
|
|
204
214
|
def cookies=(value)
|
|
205
215
|
set :cookie, value
|
|
206
216
|
end
|
|
207
217
|
|
|
208
|
-
#
|
|
218
|
+
#
|
|
209
219
|
# call-seq:
|
|
210
220
|
# easy.cookiefile = string => string
|
|
211
|
-
#
|
|
221
|
+
#
|
|
212
222
|
# Set a file that contains cookies to be sent in subsequent requests by this Curl::Easy instance.
|
|
213
|
-
#
|
|
223
|
+
#
|
|
214
224
|
# *Note* that you must set enable_cookies true to enable the cookie
|
|
215
225
|
# engine, or this option will be ignored.
|
|
216
|
-
#
|
|
226
|
+
#
|
|
217
227
|
def cookiefile=(value)
|
|
218
228
|
set :cookiefile, value
|
|
219
229
|
end
|
|
220
230
|
|
|
221
|
-
#
|
|
231
|
+
#
|
|
222
232
|
# call-seq:
|
|
223
233
|
# easy.cookiejar = string => string
|
|
224
|
-
#
|
|
234
|
+
#
|
|
225
235
|
# Set a cookiejar file to use for this Curl::Easy instance.
|
|
226
236
|
# Cookies from the response will be written into this file.
|
|
227
|
-
#
|
|
237
|
+
#
|
|
228
238
|
# *Note* that you must set enable_cookies true to enable the cookie
|
|
229
239
|
# engine, or this option will be ignored.
|
|
230
|
-
#
|
|
240
|
+
#
|
|
231
241
|
def cookiejar=(value)
|
|
232
242
|
set :cookiejar, value
|
|
233
243
|
end
|
|
@@ -405,35 +415,35 @@ module Curl
|
|
|
405
415
|
c.http_delete
|
|
406
416
|
c
|
|
407
417
|
end
|
|
408
|
-
|
|
418
|
+
|
|
409
419
|
# call-seq:
|
|
410
420
|
# Curl::Easy.download(url, filename = url.split(/\?/).first.split(/\//).last) { |curl| ... }
|
|
411
|
-
#
|
|
421
|
+
#
|
|
412
422
|
# Stream the specified url (via perform) and save the data directly to the
|
|
413
|
-
# supplied filename (defaults to the last component of the URL path, which will
|
|
423
|
+
# supplied filename (defaults to the last component of the URL path, which will
|
|
414
424
|
# usually be the filename most simple urls).
|
|
415
|
-
#
|
|
425
|
+
#
|
|
416
426
|
# If a block is supplied, it will be passed the curl instance prior to the
|
|
417
427
|
# perform call.
|
|
418
|
-
#
|
|
428
|
+
#
|
|
419
429
|
# *Note* that the semantics of the on_body handler are subtly changed when using
|
|
420
|
-
# download, to account for the automatic routing of data to the specified file: The
|
|
430
|
+
# download, to account for the automatic routing of data to the specified file: The
|
|
421
431
|
# data string is passed to the handler *before* it is written
|
|
422
|
-
# to the file, allowing the handler to perform mutative operations where
|
|
432
|
+
# to the file, allowing the handler to perform mutative operations where
|
|
423
433
|
# necessary. As usual, the transfer will be aborted if the on_body handler
|
|
424
|
-
# returns a size that differs from the data chunk size - in this case, the
|
|
434
|
+
# returns a size that differs from the data chunk size - in this case, the
|
|
425
435
|
# offending chunk will *not* be written to the file, the file will be closed,
|
|
426
436
|
# and a Curl::Err::AbortedByCallbackError will be raised.
|
|
427
437
|
def download(url, filename = url.split(/\?/).first.split(/\//).last, &blk)
|
|
428
438
|
curl = Curl::Easy.new(url, &blk)
|
|
429
|
-
|
|
439
|
+
|
|
430
440
|
output = if filename.is_a? IO
|
|
431
441
|
filename.binmode if filename.respond_to?(:binmode)
|
|
432
442
|
filename
|
|
433
443
|
else
|
|
434
444
|
File.open(filename, 'wb')
|
|
435
445
|
end
|
|
436
|
-
|
|
446
|
+
|
|
437
447
|
begin
|
|
438
448
|
old_on_body = curl.on_body do |data|
|
|
439
449
|
result = old_on_body ? old_on_body.call(data) : data.length
|
|
@@ -444,7 +454,7 @@ module Curl
|
|
|
444
454
|
ensure
|
|
445
455
|
output.close rescue IOError
|
|
446
456
|
end
|
|
447
|
-
|
|
457
|
+
|
|
448
458
|
return curl
|
|
449
459
|
end
|
|
450
460
|
end
|
data/lib/curl.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'curb_core'
|
|
|
2
2
|
require 'curl/easy'
|
|
3
3
|
require 'curl/multi'
|
|
4
4
|
require 'uri'
|
|
5
|
+
require 'cgi'
|
|
5
6
|
|
|
6
7
|
# expose shortcut methods
|
|
7
8
|
module Curl
|
|
@@ -46,7 +47,7 @@ module Curl
|
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
def self.urlalize(url, params={})
|
|
49
|
-
query_str = params.map {|k,v| "#{URI.escape(k.to_s)}=#{
|
|
50
|
+
query_str = params.map {|k,v| "#{URI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
|
|
50
51
|
if url.match(/\?/)
|
|
51
52
|
"#{url}&#{query_str}"
|
|
52
53
|
elsif query_str.size > 0
|
|
@@ -60,4 +61,8 @@ module Curl
|
|
|
60
61
|
params.respond_to?(:map) ? URI.encode_www_form(params) : (params.respond_to?(:to_s) ? params.to_s : params)
|
|
61
62
|
end
|
|
62
63
|
|
|
64
|
+
def self.reset
|
|
65
|
+
Thread.current[:curb_curl] = Curl::Easy.new
|
|
66
|
+
end
|
|
67
|
+
|
|
63
68
|
end
|
|
@@ -5,7 +5,7 @@ class ::WEBrick::BasicLog ; def log(level, data) ; end ; end
|
|
|
5
5
|
|
|
6
6
|
class BugCrashOnDebug < Test::Unit::TestCase
|
|
7
7
|
|
|
8
|
-
def
|
|
8
|
+
def test_on_progress_raise
|
|
9
9
|
server = WEBrick::HTTPServer.new( :Port => 9999 )
|
|
10
10
|
server.mount_proc("/test") do|req,res|
|
|
11
11
|
res.body = "hi"
|
|
@@ -30,4 +30,44 @@ class BugCrashOnDebug < Test::Unit::TestCase
|
|
|
30
30
|
ensure
|
|
31
31
|
server.shutdown
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
def test_on_progress_abort
|
|
35
|
+
server = WEBrick::HTTPServer.new( :Port => 9999 )
|
|
36
|
+
server.mount_proc("/test") do|req,res|
|
|
37
|
+
res.body = "hi"
|
|
38
|
+
res['Content-Type'] = "text/html"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
thread = Thread.new(server) do|srv|
|
|
42
|
+
srv.start
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# see: https://github.com/taf2/curb/issues/192,
|
|
46
|
+
# to pass:
|
|
47
|
+
#
|
|
48
|
+
# c = Curl::Easy.new('http://127.0.0.1:9999/test')
|
|
49
|
+
# c.on_progress do|x|
|
|
50
|
+
# puts "we're in the progress callback"
|
|
51
|
+
# false
|
|
52
|
+
# end
|
|
53
|
+
# c.perform
|
|
54
|
+
#
|
|
55
|
+
# notice no return keyword
|
|
56
|
+
#
|
|
57
|
+
c = Curl::Easy.new('http://127.0.0.1:9999/test')
|
|
58
|
+
c.on_progress do|x|
|
|
59
|
+
puts "we're in the progress callback"
|
|
60
|
+
return false
|
|
61
|
+
end
|
|
62
|
+
c.perform
|
|
63
|
+
|
|
64
|
+
assert false, "should not reach this point"
|
|
65
|
+
|
|
66
|
+
rescue => e
|
|
67
|
+
assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
|
|
68
|
+
c.close
|
|
69
|
+
ensure
|
|
70
|
+
server.shutdown
|
|
71
|
+
end
|
|
72
|
+
|
|
33
73
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
|
2
|
+
|
|
3
|
+
class BugIssue102 < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def test_interface
|
|
6
|
+
test = "https://api.twitter.com/1/users/show.json?screen_name=TwitterAPI&include_entities=true"
|
|
7
|
+
ip = "0.0.0.0"
|
|
8
|
+
|
|
9
|
+
c = Curl::Easy.new do |curl|
|
|
10
|
+
curl.url = test
|
|
11
|
+
curl.interface = ip
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
c.perform
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
data/tests/helper.rb
CHANGED
|
@@ -10,7 +10,12 @@ $:.unshift($LIBDIR)
|
|
|
10
10
|
$:.unshift($EXTDIR)
|
|
11
11
|
|
|
12
12
|
require 'curb'
|
|
13
|
-
|
|
13
|
+
begin
|
|
14
|
+
require 'test/unit'
|
|
15
|
+
rescue LoadError
|
|
16
|
+
gem 'test/unit'
|
|
17
|
+
require 'test/unit'
|
|
18
|
+
end
|
|
14
19
|
require 'fileutils'
|
|
15
20
|
|
|
16
21
|
$TEST_URL = "file://#{URI.escape(File.expand_path(__FILE__).tr('\\','/').tr(':','|'))}"
|
data/tests/tc_curl_download.rb
CHANGED
data/tests/tc_curl_easy.rb
CHANGED
|
@@ -4,6 +4,12 @@ class FooNoToS
|
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
class TestCurbCurlEasy < Test::Unit::TestCase
|
|
7
|
+
def test_global_reset
|
|
8
|
+
c = Curl.get($TEST_URL)
|
|
9
|
+
# in a Timeout block you should reset the thread current handle
|
|
10
|
+
Curl.reset
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
def test_threads
|
|
8
14
|
t = []
|
|
9
15
|
5.times do
|
|
@@ -645,8 +651,8 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
|
645
651
|
curl = Curl::Easy.new(TestServlet.url)
|
|
646
652
|
curl.multipart_form_post = true
|
|
647
653
|
fields = [
|
|
648
|
-
Curl::PostField.file('foo', File.expand_path(File.join(File.dirname(__FILE__),'..','README'))),
|
|
649
|
-
Curl::PostField.file('bar', File.expand_path(File.join(File.dirname(__FILE__),'..','README')))
|
|
654
|
+
Curl::PostField.file('foo', File.expand_path(File.join(File.dirname(__FILE__),'..','README.markdown'))),
|
|
655
|
+
Curl::PostField.file('bar', File.expand_path(File.join(File.dirname(__FILE__),'..','README.markdown')))
|
|
650
656
|
]
|
|
651
657
|
curl.http_post(fields)
|
|
652
658
|
assert_match /HTTP POST file upload/, curl.body_str
|
|
@@ -674,7 +680,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
|
674
680
|
def test_post_multipart_file_remote
|
|
675
681
|
curl = Curl::Easy.new(TestServlet.url)
|
|
676
682
|
curl.multipart_form_post = true
|
|
677
|
-
pf = Curl::PostField.file('readme', File.expand_path(File.join(File.dirname(__FILE__),'..','README')))
|
|
683
|
+
pf = Curl::PostField.file('readme', File.expand_path(File.join(File.dirname(__FILE__),'..','README.markdown')))
|
|
678
684
|
curl.http_post(pf)
|
|
679
685
|
assert_match /HTTP POST file upload/, curl.body_str
|
|
680
686
|
assert_match /Content-Disposition: form-data/, curl.body_str
|
|
@@ -855,7 +861,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
|
855
861
|
end
|
|
856
862
|
|
|
857
863
|
def test_post_streaming
|
|
858
|
-
readme = File.expand_path(File.join(File.dirname(__FILE__),'..','README'))
|
|
864
|
+
readme = File.expand_path(File.join(File.dirname(__FILE__),'..','README.markdown'))
|
|
859
865
|
|
|
860
866
|
pf = Curl::PostField.file("filename", readme)
|
|
861
867
|
|
|
@@ -1022,6 +1028,13 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
|
1022
1028
|
end
|
|
1023
1029
|
end
|
|
1024
1030
|
|
|
1031
|
+
def test_set_unsupported_options
|
|
1032
|
+
curl = Curl::Easy.new
|
|
1033
|
+
assert_raises TypeError do
|
|
1034
|
+
curl.set(99999, 1)
|
|
1035
|
+
end
|
|
1036
|
+
end
|
|
1037
|
+
|
|
1025
1038
|
include TestServerMethods
|
|
1026
1039
|
|
|
1027
1040
|
def setup
|
data/tests/tc_curl_multi.rb
CHANGED
|
@@ -466,7 +466,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
|
466
466
|
m.add(c)
|
|
467
467
|
m.add(c)
|
|
468
468
|
rescue => e
|
|
469
|
-
|
|
469
|
+
assert Curl::Err::MultiBadEasyHandle == e.class || Curl::Err::MultiAddedAlready == e.class
|
|
470
470
|
end
|
|
471
471
|
|
|
472
472
|
def test_multi_default_timeout
|
metadata
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: curb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.8.8
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Ross Bamford
|
|
@@ -10,7 +9,7 @@ authors:
|
|
|
10
9
|
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
|
14
13
|
dependencies: []
|
|
15
14
|
description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings
|
|
16
15
|
for the libcurl(3), a fully-featured client-side URL transfer library. cURL and
|
|
@@ -21,36 +20,37 @@ extensions:
|
|
|
21
20
|
- ext/extconf.rb
|
|
22
21
|
extra_rdoc_files:
|
|
23
22
|
- LICENSE
|
|
24
|
-
- README
|
|
23
|
+
- README.markdown
|
|
25
24
|
files:
|
|
26
25
|
- LICENSE
|
|
27
|
-
- README
|
|
26
|
+
- README.markdown
|
|
28
27
|
- Rakefile
|
|
29
28
|
- doc.rb
|
|
30
|
-
- ext/extconf.rb
|
|
31
|
-
- lib/curb.rb
|
|
32
|
-
- lib/curl/easy.rb
|
|
33
|
-
- lib/curl/multi.rb
|
|
34
|
-
- lib/curl.rb
|
|
35
29
|
- ext/curb.c
|
|
36
|
-
- ext/curb_easy.c
|
|
37
|
-
- ext/curb_errors.c
|
|
38
|
-
- ext/curb_multi.c
|
|
39
|
-
- ext/curb_postfield.c
|
|
40
|
-
- ext/curb_upload.c
|
|
41
30
|
- ext/curb.h
|
|
31
|
+
- ext/curb_easy.c
|
|
42
32
|
- ext/curb_easy.h
|
|
33
|
+
- ext/curb_errors.c
|
|
43
34
|
- ext/curb_errors.h
|
|
44
35
|
- ext/curb_macros.h
|
|
36
|
+
- ext/curb_multi.c
|
|
45
37
|
- ext/curb_multi.h
|
|
38
|
+
- ext/curb_postfield.c
|
|
46
39
|
- ext/curb_postfield.h
|
|
40
|
+
- ext/curb_upload.c
|
|
47
41
|
- ext/curb_upload.h
|
|
42
|
+
- ext/extconf.rb
|
|
43
|
+
- lib/curb.rb
|
|
44
|
+
- lib/curl.rb
|
|
45
|
+
- lib/curl/easy.rb
|
|
46
|
+
- lib/curl/multi.rb
|
|
48
47
|
- tests/alltests.rb
|
|
49
48
|
- tests/bug_crash_on_debug.rb
|
|
50
49
|
- tests/bug_crash_on_progress.rb
|
|
51
50
|
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
|
52
51
|
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
53
52
|
- tests/bug_instance_post_differs_from_class_post.rb
|
|
53
|
+
- tests/bug_issue102.rb
|
|
54
54
|
- tests/bug_multi_segfault.rb
|
|
55
55
|
- tests/bug_postfields_crash.rb
|
|
56
56
|
- tests/bug_postfields_crash2.rb
|
|
@@ -71,30 +71,29 @@ files:
|
|
|
71
71
|
- tests/unittests.rb
|
|
72
72
|
homepage: http://curb.rubyforge.org/
|
|
73
73
|
licenses: []
|
|
74
|
+
metadata: {}
|
|
74
75
|
post_install_message:
|
|
75
76
|
rdoc_options:
|
|
76
|
-
- --main
|
|
77
|
-
- README
|
|
77
|
+
- "--main"
|
|
78
|
+
- README.markdown
|
|
78
79
|
require_paths:
|
|
79
80
|
- lib
|
|
80
81
|
- ext
|
|
81
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
|
-
none: false
|
|
83
83
|
requirements:
|
|
84
|
-
- -
|
|
84
|
+
- - ">="
|
|
85
85
|
- !ruby/object:Gem::Version
|
|
86
86
|
version: '0'
|
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
|
-
none: false
|
|
89
88
|
requirements:
|
|
90
|
-
- -
|
|
89
|
+
- - ">="
|
|
91
90
|
- !ruby/object:Gem::Version
|
|
92
91
|
version: '0'
|
|
93
92
|
requirements: []
|
|
94
93
|
rubyforge_project: curb
|
|
95
|
-
rubygems_version:
|
|
94
|
+
rubygems_version: 2.4.5
|
|
96
95
|
signing_key:
|
|
97
|
-
specification_version:
|
|
96
|
+
specification_version: 4
|
|
98
97
|
summary: Ruby libcurl bindings
|
|
99
98
|
test_files:
|
|
100
99
|
- tests/alltests.rb
|
|
@@ -103,6 +102,7 @@ test_files:
|
|
|
103
102
|
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
|
104
103
|
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
|
105
104
|
- tests/bug_instance_post_differs_from_class_post.rb
|
|
105
|
+
- tests/bug_issue102.rb
|
|
106
106
|
- tests/bug_multi_segfault.rb
|
|
107
107
|
- tests/bug_postfields_crash.rb
|
|
108
108
|
- tests/bug_postfields_crash2.rb
|
|
@@ -121,4 +121,3 @@ test_files:
|
|
|
121
121
|
- tests/timeout.rb
|
|
122
122
|
- tests/timeout_server.rb
|
|
123
123
|
- tests/unittests.rb
|
|
124
|
-
has_rdoc: true
|