taf2-curb 0.2.7.3 → 0.2.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +22 -66
- data/ext/curb.h +3 -3
- data/tests/alltests.rb +3 -0
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +52 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +53 -0
- data/tests/bug_require_last_or_segfault.rb +40 -0
- data/tests/require_last_or_segfault_script.rb +36 -0
- data/tests/tc_curl_download.rb +27 -0
- metadata +21 -13
data/Rakefile
CHANGED
@@ -4,11 +4,11 @@ require 'rake/clean'
|
|
4
4
|
require 'rake/testtask'
|
5
5
|
require 'rake/rdoctask'
|
6
6
|
|
7
|
-
begin
|
8
|
-
require 'rake/gempackagetask'
|
9
|
-
rescue LoadError
|
10
|
-
$stderr.puts("Rubygems support disabled")
|
11
|
-
end
|
7
|
+
#begin
|
8
|
+
# require 'rake/gempackagetask'
|
9
|
+
#rescue LoadError
|
10
|
+
# $stderr.puts("Rubygems support disabled")
|
11
|
+
#end
|
12
12
|
|
13
13
|
CLEAN.include '**/*.o'
|
14
14
|
CLEAN.include "**/*.#{Config::MAKEFILE_CONFIG['DLEXT']}"
|
@@ -130,74 +130,30 @@ task :doc_upload => [ :doc ] do
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
-
# Packaging ------------------------------------------------
|
134
|
-
PKG_FILES = FileList[
|
135
|
-
'ext/*.rb',
|
136
|
-
'ext/*.c',
|
137
|
-
'ext/*.h',
|
138
|
-
'lib/*.rb',
|
139
|
-
'tests/**/*',
|
140
|
-
'samples/**/*',
|
141
|
-
'doc.rb',
|
142
|
-
'[A-Z]*',
|
143
|
-
]
|
144
|
-
|
145
133
|
if ! defined?(Gem)
|
146
134
|
warn "Package Target requires RubyGEMs"
|
147
135
|
else
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
s.description = <<-EOF
|
156
|
-
C-language Ruby bindings for the libcurl(3) URL transfer library.
|
157
|
-
EOF
|
158
|
-
s.extensions = 'ext/extconf.rb'
|
159
|
-
|
160
|
-
#### Which files are to be included in this gem?
|
161
|
-
|
162
|
-
s.files = PKG_FILES.to_a
|
163
|
-
|
164
|
-
#### Load-time details
|
165
|
-
s.require_path = 'lib'
|
166
|
-
|
167
|
-
#### Documentation and testing.
|
168
|
-
s.has_rdoc = true
|
169
|
-
s.extra_rdoc_files = Dir['ext/*.c'] << 'lib/curb.rb' << 'README' << 'LICENSE'
|
170
|
-
s.rdoc_options <<
|
171
|
-
'--title' << 'Curb API' <<
|
172
|
-
'--main' << 'README'
|
173
|
-
|
174
|
-
s.test_files = Dir.glob('tests/tc_*.rb')
|
175
|
-
|
176
|
-
#### Author and project details.
|
177
|
-
|
178
|
-
s.author = "Ross Bamford"
|
179
|
-
s.email = "curb-devel@rubyforge.org"
|
180
|
-
s.homepage = "http://curb.rubyforge.org"
|
181
|
-
s.rubyforge_project = "curb"
|
182
|
-
end
|
183
|
-
|
184
|
-
# Quick fix for Ruby 1.8.3 / YAML bug
|
185
|
-
if (RUBY_VERSION == '1.8.3')
|
186
|
-
def spec.to_yaml
|
187
|
-
out = super
|
188
|
-
out = '--- ' + out unless out =~ /^---/
|
189
|
-
out
|
190
|
-
end
|
136
|
+
desc 'Generate gem specification'
|
137
|
+
task :gemspec do
|
138
|
+
require 'erb'
|
139
|
+
tspec = ERB.new(File.read(File.join(File.dirname(__FILE__),'lib','curb.gemspec.erb')))
|
140
|
+
File.open(File.join(File.dirname(__FILE__),'curb.gemspec'),'wb') do|f|
|
141
|
+
f << tspec.result
|
142
|
+
end
|
191
143
|
end
|
192
144
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
145
|
+
desc 'Build gem'
|
146
|
+
task :package => :gemspec do
|
147
|
+
require 'rubygems/specification'
|
148
|
+
spec_source = File.read File.join(File.dirname(__FILE__),'curb.gemspec')
|
149
|
+
spec = nil
|
150
|
+
# see: http://gist.github.com/16215
|
151
|
+
Thread.new { spec = eval("$SAFE = 3\n#{spec_source}") }.join
|
152
|
+
spec.validate
|
153
|
+
Gem::Builder.new(spec).build
|
154
|
+
end
|
198
155
|
end
|
199
156
|
|
200
|
-
|
201
157
|
# --------------------------------------------------------------------
|
202
158
|
# Creating a release
|
203
159
|
desc "Make a new release (Requires SVN commit / webspace access)"
|
data/ext/curb.h
CHANGED
@@ -20,12 +20,12 @@
|
|
20
20
|
#include "curb_macros.h"
|
21
21
|
|
22
22
|
// These should be managed from the Rake 'release' task.
|
23
|
-
#define CURB_VERSION "0.2.7.
|
23
|
+
#define CURB_VERSION "0.2.7.4"
|
24
24
|
#define CURB_VER_NUM 224
|
25
25
|
#define CURB_VER_MAJ 0
|
26
26
|
#define CURB_VER_MIN 2
|
27
|
-
#define CURB_VER_MIC
|
28
|
-
#define CURB_VER_PATCH
|
27
|
+
#define CURB_VER_MIC 7
|
28
|
+
#define CURB_VER_PATCH 4
|
29
29
|
|
30
30
|
|
31
31
|
// Maybe not yet defined in Ruby
|
data/tests/alltests.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
require 'webrick'
|
3
|
+
class ::WEBrick::HTTPServer ; def access_log(config, req, res) ; end ; end
|
4
|
+
class ::WEBrick::BasicLog ; def log(level, data) ; end ; end
|
5
|
+
|
6
|
+
class BugTestInstancePostDiffersFromClassPost < Test::Unit::TestCase
|
7
|
+
def test_bug
|
8
|
+
server = WEBrick::HTTPServer.new( :Port => 9999 )
|
9
|
+
server.mount_proc("/test") do|req,res|
|
10
|
+
sleep 0.5
|
11
|
+
res.body = "hi"
|
12
|
+
res['Content-Type'] = "text/html"
|
13
|
+
end
|
14
|
+
|
15
|
+
thread = Thread.new(server) do|srv|
|
16
|
+
srv.start
|
17
|
+
end
|
18
|
+
|
19
|
+
threads = []
|
20
|
+
timer = Time.now
|
21
|
+
|
22
|
+
5.times do |i|
|
23
|
+
t = Thread.new do
|
24
|
+
c = Curl::Easy.perform('http://localhost:9999/test')
|
25
|
+
c.header_str
|
26
|
+
end
|
27
|
+
threads << t
|
28
|
+
end
|
29
|
+
|
30
|
+
multi_responses = threads.collect do|t|
|
31
|
+
t.value
|
32
|
+
end
|
33
|
+
|
34
|
+
multi_time = (Time.now - timer)
|
35
|
+
puts "requested in #{multi_time}"
|
36
|
+
|
37
|
+
timer = Time.now
|
38
|
+
single_responses = []
|
39
|
+
5.times do |i|
|
40
|
+
c = Curl::Easy.perform('http://localhost:9999/test')
|
41
|
+
single_responses << c.header_str
|
42
|
+
end
|
43
|
+
|
44
|
+
single_time = (Time.now - timer)
|
45
|
+
puts "requested in #{single_time}"
|
46
|
+
|
47
|
+
assert single_time > multi_time
|
48
|
+
|
49
|
+
server.shutdown
|
50
|
+
thread.join
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# From Vlad Jebelev:
|
2
|
+
#
|
3
|
+
# - Second thing - I think you just probably didn't have the time to update
|
4
|
+
# instance methods yet but when I POST with a reusal of a previous curl
|
5
|
+
# instance, it doesnt' work for me, e.g. when I create a curl previously and
|
6
|
+
# then issue:
|
7
|
+
#
|
8
|
+
# c.http_post(login_url, *fields)
|
9
|
+
#
|
10
|
+
# instead of:
|
11
|
+
#
|
12
|
+
# c = Curl::Easy.http_post(login_url, *fields) do |curl|
|
13
|
+
# ...
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# then the result I am getting is quite different.
|
17
|
+
#
|
18
|
+
# ================
|
19
|
+
#
|
20
|
+
# Update:
|
21
|
+
#
|
22
|
+
# It seems that class httpost is incorrectly passing arguments down to
|
23
|
+
# instance httppost. This bug is intermittent, but results in an
|
24
|
+
# exception from the first post when it occurs.
|
25
|
+
#
|
26
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
27
|
+
|
28
|
+
class BugTestInstancePostDiffersFromClassPost < Test::Unit::TestCase
|
29
|
+
def test_bug
|
30
|
+
5.times do |i|
|
31
|
+
puts "Test ##{i}"
|
32
|
+
do_test
|
33
|
+
sleep 2
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def do_test
|
38
|
+
c = Curl::Easy.http_post('https://www.google.com/accounts/ServiceLoginAuth',
|
39
|
+
Curl::PostField.content('ltmpl','m_blanco'))
|
40
|
+
body_c, header_c = c.body_str, c.header_str
|
41
|
+
|
42
|
+
sleep 2
|
43
|
+
|
44
|
+
c.http_post('https://www.google.com/accounts/ServiceLoginAuth',
|
45
|
+
Curl::PostField.content('ltmpl','m_blanco'))
|
46
|
+
body_i, header_i = c.body_str, c.header_str
|
47
|
+
|
48
|
+
# timestamps will differ, just check first bit. We wont get here if
|
49
|
+
# the bug bites anyway...
|
50
|
+
assert_equal header_c[0..50], header_i[0..50]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# From Vlad Jebelev:
|
2
|
+
#
|
3
|
+
# - if I have a require statement after "require 'curb'" and there is a
|
4
|
+
# POST with at least 1 field, the script will fail with a segmentation
|
5
|
+
# fault, e.g. the following sequence fails every time for me (Ruby 1.8.5):
|
6
|
+
# -----------------------------------------------------------------
|
7
|
+
# require 'curb'
|
8
|
+
# require 'uri'
|
9
|
+
#
|
10
|
+
# url = 'https://www.google.com/accounts/ServiceLoginAuth'
|
11
|
+
#
|
12
|
+
# c = Curl::Easy.http_post(
|
13
|
+
# 'https://www.google.com/accounts/ServiceLoginAuth',
|
14
|
+
# [Curl:: PostField.content('ltmpl','m_blanco')] ) do |curl|
|
15
|
+
# end
|
16
|
+
# ------------------------------------------------------------------
|
17
|
+
# :..dev/util$ ruby seg.rb
|
18
|
+
# seg.rb:6: [BUG] Segmentation fault
|
19
|
+
# ruby 1.8.5 (2006-08-25) [i686-linux]
|
20
|
+
#
|
21
|
+
# Aborted
|
22
|
+
# ------------------------------------------------------------------
|
23
|
+
#
|
24
|
+
require 'test/unit'
|
25
|
+
require 'rbconfig'
|
26
|
+
|
27
|
+
$rubycmd = Config::CONFIG['RUBY_INSTALL_NAME'] || 'ruby'
|
28
|
+
|
29
|
+
class BugTestRequireLastOrSegfault < Test::Unit::TestCase
|
30
|
+
def test_bug
|
31
|
+
5.times do |i|
|
32
|
+
puts "Test ##{i}"
|
33
|
+
|
34
|
+
# will be empty string if it segfaults...
|
35
|
+
assert_equal 'success', `#$rubycmd #{File.dirname(__FILE__)}/require_last_or_segfault_script.rb`.chomp
|
36
|
+
sleep 5
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# From Vlad Jebelev:
|
2
|
+
#
|
3
|
+
# - if I have a require statement after "require 'curb'" and there is a
|
4
|
+
# POST with at least 1 field, the script will fail with a segmentation
|
5
|
+
# fault, e.g. the following sequence fails every time for me (Ruby 1.8.5):
|
6
|
+
# -----------------------------------------------------------------
|
7
|
+
# require 'curb'
|
8
|
+
# require 'uri'
|
9
|
+
#
|
10
|
+
# url = 'https://www.google.com/accounts/ServiceLoginAuth'
|
11
|
+
#
|
12
|
+
# c = Curl::Easy.http_post(
|
13
|
+
# 'https://www.google.com/accounts/ServiceLoginAuth',
|
14
|
+
# [Curl:: PostField.content('ltmpl','m_blanco')] ) do |curl|
|
15
|
+
# end
|
16
|
+
# ------------------------------------------------------------------
|
17
|
+
# :..dev/util$ ruby seg.rb
|
18
|
+
# seg.rb:6: [BUG] Segmentation fault
|
19
|
+
# ruby 1.8.5 (2006-08-25) [i686-linux]
|
20
|
+
#
|
21
|
+
# Aborted
|
22
|
+
# ------------------------------------------------------------------
|
23
|
+
#
|
24
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'ext'))
|
25
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
26
|
+
require 'curb'
|
27
|
+
require 'uri'
|
28
|
+
|
29
|
+
url = 'https://www.google.com/accounts/ServiceLoginAuth'
|
30
|
+
|
31
|
+
c = Curl::Easy.http_post('https://www.google.com/accounts/ServiceLoginAuth',
|
32
|
+
Curl:: PostField.content('ltmpl','m_blanco')) #do
|
33
|
+
# end
|
34
|
+
|
35
|
+
puts "success"
|
36
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class TestCurbCurlDownload < Test::Unit::TestCase
|
4
|
+
include TestServerMethods
|
5
|
+
|
6
|
+
def setup
|
7
|
+
server_setup(9130)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_download_url_to_file
|
11
|
+
dl_url = "http://127.0.0.1:9130/ext/curb_easy.c"
|
12
|
+
dl_path = File.join("/tmp/dl_url_test.file")
|
13
|
+
|
14
|
+
curb = Curl::Easy.download(dl_url, dl_path)
|
15
|
+
assert File.exist?(dl_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_download_bad_url_gives_404
|
19
|
+
dl_url = "http://127.0.0.1:9130/this_file_does_not_exist.html"
|
20
|
+
dl_path = File.join("/tmp/dl_url_test.file")
|
21
|
+
|
22
|
+
curb = Curl::Easy.download(dl_url, dl_path)
|
23
|
+
assert_equal Curl::Easy, curb.class
|
24
|
+
assert_equal 404, curb.response_code
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taf2-curb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.7.
|
4
|
+
version: 0.2.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Bamford
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2009-02-22 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -28,20 +28,21 @@ files:
|
|
28
28
|
- README
|
29
29
|
- Rakefile
|
30
30
|
- doc.rb
|
31
|
-
- ext/
|
31
|
+
- ext/extconf.rb
|
32
|
+
- lib/curb.rb
|
33
|
+
- lib/curl.rb
|
34
|
+
- ext/curb.c
|
35
|
+
- ext/curb_postfield.c
|
36
|
+
- ext/curb_multi.c
|
37
|
+
- ext/curb_errors.c
|
38
|
+
- ext/curb_easy.c
|
32
39
|
- ext/curb_easy.h
|
33
40
|
- ext/curb_errors.h
|
34
41
|
- ext/curb_macros.h
|
35
|
-
- ext/
|
42
|
+
- ext/curb.h
|
36
43
|
- ext/curb_postfield.h
|
37
|
-
- ext/
|
38
|
-
- ext/
|
39
|
-
- ext/curb_errors.c
|
40
|
-
- ext/curb_multi.c
|
41
|
-
- ext/curb_postfield.c
|
42
|
-
- lib/curl.rb
|
43
|
-
- ext/extconf.rb
|
44
|
-
- lib/curb.rb
|
44
|
+
- ext/curb_config.h
|
45
|
+
- ext/curb_multi.h
|
45
46
|
has_rdoc: true
|
46
47
|
homepage: http://curb.rubyforge.org/
|
47
48
|
post_install_message:
|
@@ -49,6 +50,7 @@ rdoc_options:
|
|
49
50
|
- --main
|
50
51
|
- README
|
51
52
|
require_paths:
|
53
|
+
- lib
|
52
54
|
- ext
|
53
55
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
56
|
requirements:
|
@@ -70,8 +72,14 @@ signing_key:
|
|
70
72
|
specification_version: 2
|
71
73
|
summary: Ruby libcurl bindings
|
72
74
|
test_files:
|
73
|
-
- tests/tc_curl_easy.rb
|
74
75
|
- tests/tc_curl_multi.rb
|
75
76
|
- tests/tc_curl_postfield.rb
|
77
|
+
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
76
78
|
- tests/unittests.rb
|
79
|
+
- tests/bug_require_last_or_segfault.rb
|
80
|
+
- tests/bug_instance_post_differs_from_class_post.rb
|
81
|
+
- tests/tc_curl_download.rb
|
82
|
+
- tests/alltests.rb
|
77
83
|
- tests/helper.rb
|
84
|
+
- tests/tc_curl_easy.rb
|
85
|
+
- tests/require_last_or_segfault_script.rb
|