curb 0.9.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,63 +2,63 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
2
 
3
3
  class TestCurbCurlPostfield < Test::Unit::TestCase
4
4
  def test_private_new
5
- assert_raise(NoMethodError) { Curl::PostField.new }
5
+ assert_raise(NoMethodError) { Curl::PostField.new }
6
6
  end
7
-
7
+
8
8
  def test_new_content_01
9
9
  pf = Curl::PostField.content('foo', 'bar')
10
-
10
+
11
11
  assert_equal 'foo', pf.name
12
12
  assert_equal 'bar', pf.content
13
13
  assert_nil pf.content_type
14
14
  assert_nil pf.local_file
15
- assert_nil pf.remote_file
15
+ assert_nil pf.remote_file
16
16
  assert_nil pf.set_content_proc
17
17
  end
18
-
18
+
19
19
  def test_new_content_02
20
20
  pf = Curl::PostField.content('foo', 'bar', 'text/html')
21
-
21
+
22
22
  assert_equal 'foo', pf.name
23
23
  assert_equal 'bar', pf.content
24
24
  assert_equal 'text/html', pf.content_type
25
25
  assert_nil pf.local_file
26
26
  assert_nil pf.remote_file
27
- assert_nil pf.set_content_proc
28
- end
29
-
27
+ assert_nil pf.set_content_proc
28
+ end
29
+
30
30
  def test_new_content_03
31
31
  l = lambda { |field| "never gets run" }
32
32
  pf = Curl::PostField.content('foo', &l)
33
-
33
+
34
34
  assert_equal 'foo', pf.name
35
35
  assert_nil pf.content
36
36
  assert_nil pf.content_type
37
37
  assert_nil pf.local_file
38
38
  assert_nil pf.remote_file
39
-
39
+
40
40
  # N.B. This doesn't just get the proc, but also removes it.
41
41
  assert_equal l, pf.set_content_proc
42
- end
42
+ end
43
43
 
44
44
  def test_new_content_04
45
45
  l = lambda { |field| "never gets run" }
46
46
  pf = Curl::PostField.content('foo', 'text/html', &l)
47
-
47
+
48
48
  assert_equal 'foo', pf.name
49
49
  assert_nil pf.content
50
50
  assert_equal 'text/html', pf.content_type
51
51
  assert_nil pf.local_file
52
52
  assert_nil pf.remote_file
53
-
53
+
54
54
  # N.B. This doesn't just get the proc, but also removes it.
55
55
  assert_equal l, pf.set_content_proc
56
- end
56
+ end
57
57
 
58
58
 
59
59
  def test_new_file_01
60
60
  pf = Curl::PostField.file('foo', 'localname')
61
-
61
+
62
62
  assert_equal 'foo', pf.name
63
63
  assert_equal 'localname', pf.local_file
64
64
  assert_equal 'localname', pf.remote_file
@@ -67,44 +67,44 @@ class TestCurbCurlPostfield < Test::Unit::TestCase
67
67
  assert_nil pf.content
68
68
  assert_nil pf.set_content_proc
69
69
  end
70
-
70
+
71
71
  def test_new_file_02
72
72
  pf = Curl::PostField.file('foo', 'localname', 'remotename')
73
-
73
+
74
74
  assert_equal 'foo', pf.name
75
75
  assert_equal 'localname', pf.local_file
76
76
  assert_equal 'remotename', pf.remote_file
77
77
  assert_nil pf.content_type
78
78
  assert_nil pf.content
79
79
  assert_nil pf.set_content_proc
80
- end
81
-
80
+ end
81
+
82
82
  def test_new_file_03
83
83
  l = lambda { |field| "never gets run" }
84
84
  pf = Curl::PostField.file('foo', 'remotename', &l)
85
-
85
+
86
86
  assert_equal 'foo', pf.name
87
87
  assert_equal 'remotename', pf.remote_file
88
88
  assert_nil pf.local_file
89
89
  assert_nil pf.content_type
90
90
  assert_nil pf.content
91
-
91
+
92
92
  # N.B. This doesn't just get the proc, but also removes it.
93
93
  assert_equal l, pf.set_content_proc
94
- end
94
+ end
95
95
 
96
96
  def test_new_file_04
97
97
  assert_raise(ArgumentError) do
98
98
  # no local name, no block
99
99
  Curl::PostField.file('foo')
100
100
  end
101
-
101
+
102
102
  assert_raise(ArgumentError) do
103
103
  # no remote name with block
104
104
  Curl::PostField.file('foo') { |field| "never runs" }
105
105
  end
106
106
  end
107
-
107
+
108
108
  def test_new_file_05
109
109
  # local gets ignored when supplying a block, but remote
110
110
  # is still set up properly.
@@ -118,15 +118,15 @@ class TestCurbCurlPostfield < Test::Unit::TestCase
118
118
  assert_nil pf.content
119
119
 
120
120
  assert_equal l, pf.set_content_proc
121
- end
122
-
121
+ end
122
+
123
123
  def test_to_s_01
124
- pf = Curl::PostField.content('foo', 'bar')
124
+ pf = Curl::PostField.content('foo', 'bar')
125
125
  assert_equal "foo=bar", pf.to_s
126
126
  end
127
127
 
128
128
  def test_to_s_02
129
- pf = Curl::PostField.content('foo', 'bar ton')
129
+ pf = Curl::PostField.content('foo', 'bar ton')
130
130
  assert_equal "foo=bar%20ton", pf.to_s
131
131
  end
132
132
 
@@ -0,0 +1,37 @@
1
+ class TestCurbCurlProtocols < Test::Unit::TestCase
2
+ include TestServerMethods
3
+
4
+ def setup
5
+ @easy = Curl::Easy.new
6
+ @easy.set :protocols, Curl::CURLPROTO_HTTP | Curl::CURLPROTO_HTTPS
7
+ @easy.follow_location = true
8
+ server_setup
9
+ end
10
+
11
+ def test_protocol_allowed
12
+ @easy.set :url, "http://127.0.0.1:9129/this_file_does_not_exist.html"
13
+ @easy.perform
14
+ assert_equal 404, @easy.response_code
15
+ end
16
+
17
+ def test_protocol_denied
18
+ @easy.set :url, "gopher://google.com/"
19
+ assert_raises Curl::Err::UnsupportedProtocolError do
20
+ @easy.perform
21
+ end
22
+ end
23
+
24
+ def test_redir_protocol_allowed
25
+ @easy.set :url, TestServlet.url + "/redirect"
26
+ @easy.set :redir_protocols, Curl::CURLPROTO_HTTP
27
+ @easy.perform
28
+ end
29
+
30
+ def test_redir_protocol_denied
31
+ @easy.set :url, TestServlet.url + "/redirect"
32
+ @easy.set :redir_protocols, Curl::CURLPROTO_HTTPS
33
+ assert_raises Curl::Err::UnsupportedProtocolError do
34
+ @easy.perform
35
+ end
36
+ end
37
+ end
data/tests/timeout.rb CHANGED
@@ -17,9 +17,13 @@ class TestCurbTimeouts < Test::Unit::TestCase
17
17
  def test_overall_timeout_on_dead_transfer
18
18
  curl = Curl::Easy.new(wait_url(2))
19
19
  curl.timeout = 1
20
- assert_raise(Curl::Err::TimeoutError) do
20
+ exception = assert_raise(Curl::Err::TimeoutError) do
21
21
  curl.http_get
22
22
  end
23
+ assert_match(
24
+ /^Timeout was reached: Operation timed out after/,
25
+ exception.message
26
+ )
23
27
  end
24
28
 
25
29
  def test_overall_timeout_ms_on_dead_transfer
@@ -44,16 +48,20 @@ class TestCurbTimeouts < Test::Unit::TestCase
44
48
  curl = Curl::Easy.new(serve_url(100, 2, 3))
45
49
  curl.timeout = 1
46
50
  # transfer is aborted despite data being exchanged
47
- assert_raise(Curl::Err::TimeoutError) do
51
+ exception = assert_raise(Curl::Err::TimeoutError) do
48
52
  curl.http_get
49
53
  end
54
+ assert_match(
55
+ /^Timeout was reached: Operation timed out after/,
56
+ exception.message
57
+ )
50
58
  end
51
59
 
52
60
  def test_low_speed_time_on_slow_transfer
53
61
  curl = Curl::Easy.new(serve_url(100, 1, 3))
54
62
  curl.low_speed_time = 2
55
63
  # use default low_speed_limit of 1
56
- assert true, curl.http_get
64
+ assert_equal true, curl.http_get
57
65
  end
58
66
 
59
67
  def test_low_speed_time_on_very_slow_transfer
@@ -63,18 +71,26 @@ class TestCurbTimeouts < Test::Unit::TestCase
63
71
  # XXX for some reason this test fails if low speed limit is not specified
64
72
  curl.low_speed_limit = 1
65
73
  # use default low_speed_limit of 1
66
- assert_raise(Curl::Err::TimeoutError) do
74
+ exception = assert_raise(Curl::Err::TimeoutError) do
67
75
  curl.http_get
68
76
  end
77
+ assert_match(
78
+ /^Timeout was reached: Operation too slow/,
79
+ exception.message
80
+ )
69
81
  end
70
82
 
71
83
  def test_low_speed_limit_on_slow_transfer
72
84
  curl = Curl::Easy.new(serve_url(10, 1, 3))
73
85
  curl.low_speed_time = 2
74
86
  curl.low_speed_limit = 1000
75
- assert_raise(Curl::Err::TimeoutError) do
87
+ exception = assert_raise(Curl::Err::TimeoutError) do
76
88
  curl.http_get
77
89
  end
90
+ assert_match(
91
+ /^Timeout was reached: Operation too slow/,
92
+ exception.message
93
+ )
78
94
  end
79
95
 
80
96
  def test_clearing_low_speed_time
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Bamford
8
8
  - Todd A. Fisher
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-11 00:00:00.000000000 Z
12
+ date: 2022-04-29 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings
15
15
  for the libcurl(3), a fully-featured client-side URL transfer library. cURL and
@@ -26,6 +26,7 @@ files:
26
26
  - README.markdown
27
27
  - Rakefile
28
28
  - doc.rb
29
+ - ext/banned.h
29
30
  - ext/curb.c
30
31
  - ext/curb.h
31
32
  - ext/curb_easy.c
@@ -51,6 +52,7 @@ files:
51
52
  - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
52
53
  - tests/bug_instance_post_differs_from_class_post.rb
53
54
  - tests/bug_issue102.rb
55
+ - tests/bug_issue277.rb
54
56
  - tests/bug_multi_segfault.rb
55
57
  - tests/bug_postfields_crash.rb
56
58
  - tests/bug_postfields_crash2.rb
@@ -63,17 +65,20 @@ files:
63
65
  - tests/tc_curl.rb
64
66
  - tests/tc_curl_download.rb
65
67
  - tests/tc_curl_easy.rb
68
+ - tests/tc_curl_easy_resolve.rb
66
69
  - tests/tc_curl_easy_setopt.rb
70
+ - tests/tc_curl_maxfilesize.rb
67
71
  - tests/tc_curl_multi.rb
68
72
  - tests/tc_curl_postfield.rb
73
+ - tests/tc_curl_protocols.rb
69
74
  - tests/timeout.rb
70
75
  - tests/timeout_server.rb
71
76
  - tests/unittests.rb
72
- homepage: http://curb.rubyforge.org/
77
+ homepage: https://github.com/taf2/curb
73
78
  licenses:
74
79
  - MIT
75
80
  metadata: {}
76
- post_install_message:
81
+ post_install_message:
77
82
  rdoc_options:
78
83
  - "--main"
79
84
  - README.markdown
@@ -91,34 +96,37 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
96
  - !ruby/object:Gem::Version
92
97
  version: '0'
93
98
  requirements: []
94
- rubyforge_project: curb
95
- rubygems_version: 2.4.3
96
- signing_key:
99
+ rubygems_version: 3.1.4
100
+ signing_key:
97
101
  specification_version: 4
98
102
  summary: Ruby libcurl bindings
99
103
  test_files:
104
+ - tests/tc_curl_multi.rb
100
105
  - tests/alltests.rb
101
- - tests/bug_crash_on_debug.rb
102
- - tests/bug_crash_on_progress.rb
103
- - tests/bug_curb_easy_blocks_ruby_threads.rb
104
- - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
105
- - tests/bug_instance_post_differs_from_class_post.rb
106
- - tests/bug_issue102.rb
107
- - tests/bug_multi_segfault.rb
106
+ - tests/tc_curl_easy_setopt.rb
107
+ - tests/tc_curl.rb
108
108
  - tests/bug_postfields_crash.rb
109
+ - tests/bug_crash_on_progress.rb
110
+ - tests/helper.rb
111
+ - tests/bug_issue277.rb
109
112
  - tests/bug_postfields_crash2.rb
110
113
  - tests/bug_require_last_or_segfault.rb
111
- - tests/bugtests.rb
112
- - tests/helper.rb
113
- - tests/mem_check.rb
114
+ - tests/timeout.rb
115
+ - tests/bug_crash_on_debug.rb
116
+ - tests/unittests.rb
117
+ - tests/tc_curl_protocols.rb
118
+ - tests/bug_issue102.rb
119
+ - tests/bug_curb_easy_blocks_ruby_threads.rb
120
+ - tests/bug_multi_segfault.rb
121
+ - tests/bug_instance_post_differs_from_class_post.rb
114
122
  - tests/require_last_or_segfault_script.rb
115
- - tests/signals.rb
116
- - tests/tc_curl.rb
123
+ - tests/timeout_server.rb
117
124
  - tests/tc_curl_download.rb
118
125
  - tests/tc_curl_easy.rb
119
- - tests/tc_curl_easy_setopt.rb
120
- - tests/tc_curl_multi.rb
126
+ - tests/mem_check.rb
121
127
  - tests/tc_curl_postfield.rb
122
- - tests/timeout.rb
123
- - tests/timeout_server.rb
124
- - tests/unittests.rb
128
+ - tests/tc_curl_maxfilesize.rb
129
+ - tests/bugtests.rb
130
+ - tests/tc_curl_easy_resolve.rb
131
+ - tests/signals.rb
132
+ - tests/bug_curb_easy_post_with_string_no_content_length_header.rb