ghazel-curb 0.5.9.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.
@@ -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.expand_path(File.join(File.dirname(__FILE__), '..', 'ext')))
25
+ $:.unshift(File.expand_path(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,32 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
+
3
+ class TestCurbCurlDownload < Test::Unit::TestCase
4
+ include TestServerMethods
5
+
6
+ def setup
7
+ server_setup
8
+ end
9
+
10
+ def test_download_url_to_file
11
+ dl_url = "http://127.0.0.1:9129/ext/curb_easy.c"
12
+ dl_path = File.join(Dir::tmpdir, "dl_url_test.file")
13
+
14
+ curb = Curl::Easy.download(dl_url, dl_path)
15
+ assert File.exist?(dl_path)
16
+ assert_equal File.read(File.join(File.dirname(__FILE__), '..','ext','curb_easy.c')), File.read(dl_path)
17
+ ensure
18
+ File.unlink(dl_path) if File.exist?(dl_path)
19
+ end
20
+
21
+ def test_download_bad_url_gives_404
22
+ dl_url = "http://127.0.0.1:9129/this_file_does_not_exist.html"
23
+ dl_path = File.join(Dir::tmpdir, "dl_url_test.file")
24
+
25
+ curb = Curl::Easy.download(dl_url, dl_path)
26
+ assert_equal Curl::Easy, curb.class
27
+ assert_equal 404, curb.response_code
28
+ ensure
29
+ File.unlink(dl_path) if File.exist?(dl_path)
30
+ end
31
+
32
+ end