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.
- data/LICENSE +51 -0
 - data/README +157 -0
 - data/Rakefile +297 -0
 - data/doc.rb +42 -0
 - data/ext/curb.c +339 -0
 - data/ext/curb.h +50 -0
 - data/ext/curb_easy.c +2932 -0
 - data/ext/curb_easy.h +103 -0
 - data/ext/curb_errors.c +630 -0
 - data/ext/curb_errors.h +128 -0
 - data/ext/curb_macros.h +114 -0
 - data/ext/curb_multi.c +487 -0
 - data/ext/curb_multi.h +26 -0
 - data/ext/curb_postfield.c +511 -0
 - data/ext/curb_postfield.h +40 -0
 - data/ext/curb_upload.c +80 -0
 - data/ext/curb_upload.h +30 -0
 - data/ext/extconf.rb +162 -0
 - data/lib/curb.rb +184 -0
 - data/lib/curl.rb +2 -0
 - 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_multi_segfault.rb +10 -0
 - data/tests/bug_require_last_or_segfault.rb +40 -0
 - data/tests/helper.rb +168 -0
 - data/tests/require_last_or_segfault_script.rb +36 -0
 - data/tests/tc_curl_download.rb +32 -0
 - data/tests/tc_curl_easy.rb +664 -0
 - data/tests/tc_curl_multi.rb +421 -0
 - data/tests/tc_curl_postfield.rb +141 -0
 - data/tests/unittests.rb +2 -0
 - metadata +89 -0
 
| 
         @@ -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
         
     |