Code Monkey home page Code Monkey logo

curb's People

Contributors

amfranz avatar bf4 avatar brycethornton avatar chuyeow avatar ctrochalakis avatar fncontroloption avatar foobarwidget avatar geronime avatar ghazel avatar hpvb avatar hsbt avatar igrigorik avatar itszootime avatar jesterovskiy avatar jheiss avatar jibi avatar jniebuhr avatar lehresman avatar luke-hill avatar manelli avatar mkauf avatar mocoso avatar nevir avatar nobu avatar olleolleolle avatar paulodiniz avatar robuye avatar roscopeco avatar taf2 avatar wwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

curb's Issues

Build issue on Windows with mingw/msys

C:/oneclick-rubyinstaller/sandbox/ruby19_mingw/bin/ruby.exe extconf.rb --with-curl-dir=C:/curl-7.19.5-devel-mingw32
checking for curl-config... no
checking for main() in -lcurl... yes
checking for curl/curl.h... yes
checking for curlinfo_redirect_time... yes
checking for curlinfo_response_code... yes
checking for curlinfo_filetime... yes
checking for curlinfo_redirect_count... yes
checking for curlinfo_os_errno... yes
checking for curlinfo_num_connects... yes
checking for curlinfo_ftp_entry_path... yes
checking for curl_version_ssl... yes
checking for curl_version_libz... yes
checking for curl_version_ntlm... yes
checking for curl_version_gssnegotiate... yes
checking for curl_version_debug... yes
checking for curl_version_asynchdns... yes
checking for curl_version_spnego... yes
checking for curl_version_largefile... yes
checking for curl_version_idn... yes
checking for curl_version_sspi... yes
checking for curl_version_conv... yes
checking for curlproxy_http... yes
checking for curlproxy_socks4... yes
checking for curlproxy_socks5... yes
checking for curlauth_basic... yes
checking for curlauth_digest... yes
checking for curlauth_gssnegotiate... yes
checking for curlauth_ntlm... yes
checking for curlauth_anysafe... yes
checking for curlauth_any... yes
checking for curle_tftp_notfound... yes
checking for curle_tftp_perm... yes
checking for curle_tftp_diskfull... yes
checking for curle_tftp_illegal... yes
checking for curle_tftp_unknownid... yes
checking for curle_tftp_exists... yes
checking for curle_tftp_nosuchuser... yes
checking for curle_send_fail_rewind... yes
checking for curle_ssl_engine_initfailed... yes
checking for curle_login_denied... yes
checking for curlmopt_maxconnects... yes
checking for curle_conv_failed... yes
checking for curle_conv_reqd... yes
checking for curle_ssl_cacert_badfile... yes
checking for curle_remote_file_not_found... yes
checking for curle_ssh... yes
checking for curle_ssl_shutdown_failed... yes
checking for curle_again... yes
checking for curle_ssl_crl_badfile... yes
checking for curle_ssl_issuer_error... yes
checking for curlm_bad_socket... yes
checking for curlm_unknown_option... yes
checking for curl_multi_timeout()... no
checking for curl_multi_fdset()... no
checking for curl_multi_perform()... no
checking for Ruby 1.9 Hash... yes
checking for Ruby 1.9 st.h... yes
checking for curl_easy_escape... yes
creating curb_config.h
creating Makefile

make
gcc -I. -IC:/oneclick-rubyinstaller/sandbox/ruby19_mingw/include/ruby-1.9.1/i386-mingw32 -I/C/oneclick-rubyinstaller/sandbox/ruby19_mingw/include/ruby-1.9.1/ruby/backward -I/C/oneclick-rubyinstaller/sandbox/ruby19_mingw/include/ruby-1.9.1 -I. -DRUBY_EXTCONF_H="curb_config.h" -IC:/curl-7.19.5-devel-mingw32/include -O2 -g -Wall -Wno-parentheses -Wall -o curb.o -c curb.c
In file included from curb.h:15,
from curb.c:8:
curb_easy.h:31: error: syntax error before ';' token
make: *** [curb.o] Error 1

error LNK2001: unresolved external symbol _rb_hash_lookup

The new macro rb_easy_nil uses rb_hash_lookup, which is not present in ruby 1.8.6 patchlevel 287. Is it possible to avoid using it? You could also hack around it, as I did, by copying the implementation from 1.8.7 in to the curb project under a different name.

Using curb on Windows

I am trying to install the curb gem. Since I need to have "A working (lib)curl installation, with development stuff" installed on my computer, I went to the cURL Download Wizard and downloaded this package.

But adding the bin into my PATH did not produce improvement and I still got an error when I try to install the curb gem, such as:

extconf.rb:19: Can't find libcurl or curl/curl.h (RuntimeError)

Even though, curl is already in the PATH.

I also tried raking the gem with this command:

rake install EXTCONF_OPTS='--with-curl-dir=B:\curl'

But all it fails saying "make failed" and throwing a bunch of errors like this:

C:/Ruby/lib/ruby/gems/1.8/gems/curb-0.7.7.1/ext/curb_postfield.c:76: undefined reference to 'imp_curl_formadd'

retrying a Curl::Easy

I'm attempting to retry a Curl::Easy request if it fails for some reason.

There are two solvable issues with this:

  • Re-using the same Curl::Easy handle results in "in `perform': wrong argument type nil (expected Data) (TypeError)". I believe this can be solved by resetting "rbce->self = Qnil;" earlier in rb_curl_mutli_handle_complete, and keeping a reference to the old value for the remainder of the function (for calls to rb_funcall).
  • Adding a Curl::Easy when there is no remaining work to be done in the Curl::Mutli does not keep the perform loop running. I solved this below by simply looping, but the Curl::Multi loop could be changed to check before exiting.
require 'curb'

m = Curl::Multi.new

tries = 2

c1 = Curl::Easy.new('http://thisis$broken.com') do |curl|
  curl.verbose = true
  curl.on_failure {|c,e|
    if tries > 0
      tries -= 1
      m.add(c)
    end
  }
end

tries -= 1
m.add(c1)

while not m.requests.empty?
  m.perform
end

Segfault when using an integer value for post field

post_data = []
post_data << Curl::PostField.content('document_id', 5)
c = Curl::Easy.new(url)
c.http_post(*post_data)
=> Segfault

When replacing 5 with "5" in the PostField, then it works. I think this must be a bug in the C-binding parameter parsing. I don't know enough about MRI's C extension protocol to suggest a patch for this, but this has cost us a bunch of time.

Bus Error on http_post

I'm having some issues getting this post example working... feel like I've must have missed some step in the installation process.

require 'rubygems'
require 'curb'

Curl::Easy.new('http://google.com') do |curl|
  curl.http_post('blah')
end

And I get the following when I run this...

untitled:5: [BUG] Bus Error
ruby 1.8.6 (2008-08-11) [universal-darwin9.0]

Platform

OS X 10.5.7 (Intel)

$ ruby --version
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]

$ curl --version
curl 7.19.2 (i386-apple-darwin9.5.0) libcurl/7.19.2 zlib/1.2.3
Protocols: tftp ftp telnet dict http file 
Features: Largefile libz 

I cloned your github repository, then 'rake install', 'rake package' and 'sudo gem install curb-0.5.0.0.gem' (Looked like all the tests passed).

Any help is appreciated.

Thanks,
Shad

Installation issue

I get a weird error when attempting to install:

ld: warning: in /usr/lib/libSystemStubs.a, missing required architecture ppc64 in file
ld: warning: in /usr/lib/libSystem.dylib, missing required architecture ppc64 in file
lipo: can't open input file: /var/tmp//ccvBanUf.out (No such file or directory)
make: *** [curb_core.bundle] Error 1

Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/ext/gem_make.out

I'm running Mac OS X 10.6.1, and MacPorts.

Curb on windows XP

Can it be installed on windows? i've tried the ming download but no succes it says gem installed but whe i install other gems based on curb i get this:
c:/ruby/bin/ruby.exe extconf.rb --with-curl-lib=c:\curl\lib
checking for curl-config... no
checking for main() in curl.lib... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Where do I have to place lib4-curl.dll ?

Segmentation fault when adding Curl::Easy instances to a Curl::Multi

I'm getting a segmentation fault when I add Curl:Easy instances to a running Curl::Multi instance. The Curl:Easy instances are added from on_success / on_failure handlers. The problem is sporadic but shows up eventually after a couple of minutes when running in a continuous loop.

I'm currently running Ruby 1.9.1 and Curb 0.6.0.0. I have tested with different versions of Curb but get always the same result.

Any idea?

This is the console dump:

[BUG] Segmentation fault
ruby 1.9.1p376 (2009-12-07 revision 26041) [x86_64-linux]

-- control frame ----------
c:0013 p:---- s:0044 b:0044 l:000043 d:000043 CFUNC :add
c:0012 p:0105 s:0040 b:0040 l:001628 d:001628 METHOD feedzilla.rb:86
c:0011 p:0035 s:0033 b:0033 l:002408 d:000032 BLOCK feedzilla.rb:69
c:0010 p:---- s:0030 b:0030 l:000029 d:000029 FINISH
c:0009 p:---- s:0028 b:0028 l:000027 d:000027 CFUNC :call
c:0008 p:---- s:0026 b:0026 l:000025 d:000025 CFUNC :perform
c:0007 p:0117 s:0023 b:0023 l:000022 d:000022 METHOD feedzilla.rb:53
c:0006 p:0024 s:0016 b:0016 l:0023f8 d:000015 BLOCK feedzilla.rb:96
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :each
c:0003 p:0084 s:0008 b:0008 l:0023f8 d:001418 EVAL feedzilla.rb:95
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH

c:0001 p:0000 s:0002 b:0002 l:0023f8 d:0023f8 TOP

-- Ruby level backtrace information-----------------------------------------

feedzilla.rb:86:in add
feedzilla.rb:86:in add_url_to_multi
feedzilla.rb:69:in block in add_url_to_multi
feedzilla.rb:53:in call
feedzilla.rb:53:in perform
feedzilla.rb:53:in fetch
feedzilla.rb:96:in block in


feedzilla.rb:95:in each
feedzilla.rb:95:in

-- C level backtrace information -------------------------------------------
0x4eb69b ruby(rb_vm_bugreport+0x3b) [0x4eb69b]
0x51a160 ruby [0x51a160]
0x51a2d1 ruby(rb_bug+0xb1) [0x51a2d1]
0x495cef ruby [0x495cef]
0x2aaaaacda0f0 /lib/libpthread.so.0 [0x2aaaaacda0f0]
0x49bb1e ruby(st_lookup+0xe) [0x49bb1e]
0x4d7f4f ruby [0x4d7f4f]
0x4d7fb3 ruby(rb_get_method_body+0x23) [0x4d7fb3]
0x4db653 ruby [0x4db653]
0x4dbed7 ruby(rb_funcall+0x147) [0x4dbed7]
0x4a0f43 ruby(rb_obj_as_string+0x83) [0x4a0f43]
0x2aaaac03952d /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/curb-0.6.0.0/lib/curb_core.so(ruby_curl_easy_setup+0x80d) [0x2aaaac03952d]
0x2aaaac033e4f /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/curb-0.6.0.0/lib/curb_core.so(ruby_curl_multi_add+0x7f) [0x2aaaac033e4f]
0x4d97a0 ruby [0x4d97a0]
0x4dea90 ruby [0x4dea90]
0x4dfaa4 ruby [0x4dfaa4]
0x4e4c5b ruby [0x4e4c5b]
0x4e740d ruby(rb_vm_invoke_proc+0x42d) [0x4e740d]
0x4db7d9 ruby [0x4db7d9]
0x4dbed7 ruby(rb_funcall+0x147) [0x4dbed7]
0x2aaaac033ab1 /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/curb-0.6.0.0/lib/curb_core.so [0x2aaaac033ab1]
0x2aaaac033d1b /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/curb-0.6.0.0/lib/curb_core.so(ruby_curl_multi_perform+0x21b) [0x2aaaac033d1b]
0x4d97a0 ruby [0x4d97a0]
0x4dea90 ruby [0x4dea90]
0x4dfaa4 ruby [0x4dfaa4]
0x4e4c5b ruby [0x4e4c5b]
0x4e5367 ruby [0x4e5367]
0x4e63cc ruby(rb_yield+0x6c) [0x4e63cc]
0x46b9f1 ruby [0x46b9f1]
0x4d97a0 ruby [0x4d97a0]
0x4dea90 ruby [0x4dea90]
0x4dfaa4 ruby [0x4dfaa4]
0x4e4c5b ruby [0x4e4c5b]
0x4e4e29 ruby(rb_iseq_eval_main+0xa9) [0x4e4e29]
0x4195dc ruby(ruby_exec_node+0xac) [0x4195dc]
0x41ad43 ruby(ruby_run_node+0x33) [0x41ad43]
0x41817d ruby(main+0x4d) [0x41817d]
0x2aaaab7d0466 /lib/libc.so.6(__libc_start_main+0xe6) [0x2aaaab7d0466]
0x418069 ruby [0x418069]

Content-Length header not reset on redirect

Not sure if this should be considered a bug or not, but if the user explicitly sets the Content-Length header in a typical PRG situation, the header will be set also in the GET even if no body is sent, causing the request to hang.

The following scripts illustrates the problem:

require "rubygems"
require "curb"
require "rack"

class Server
  
  def call(env)
    req = Rack::Request.new(env)
    
    p :content_length => req.content_length
    
    case req.path
    when '/redirect_me'
      [
        303, 
        {'Location' => "#{base_url}/", "Connection" => "close"}, 
        []
      ]
    else
      p :body => req.body.read
      [200, {}, ["ok"]]
    end
  end
  
  def base_url
    "http://localhost:#{port}"
  end
  
  def port
    1234
  end
  
  def run
    Thread.new { Rack::Handler::Thin.run(self, :Port => port) }
  end
  
end


s = Server.new
s.run

sleep 1

client = Curl::Easy.new
client.follow_location = true
client.verbose = true
client.url = "#{s.base_url}/redirect_me"

client.post_body = "hello world"
client.headers['Content-Length'] = '11'
client.http_post

# server hangs, trying to read the 11 bytes off the empty body

curb should expose curl_easy_setopt

As detailed in issue #48, curb does not directly allow setting certain timeout options available in curl. This would have been a minor inconvenience if curb exposed curl_easy_setopt call (and corresponding multi-call, if any). Even without any CURLOPT_* constants defined I could still pass appropriate magic numbers to curl_easy_setopt and have a workaround for timeout functionality until a better solution is put in place. Currently I have no choice but to edit C extension code, followed by distributing and installing custom packages to/on a number of development and production systems.

Curb should expose curl_easy_setopt, perhaps with a warning that it is possible to break things by passing certain values to it (e.g. options that take C strings as arguments for example), for cases when it does not provide a "native" interface to some functionality.

Segmentation fault passing symbol to Curl::Easy#http

This is using ruby-1.9.1-p378 and curb-0.7.7.1:

$ ruby -r curb -e "c = Curl::Easy.new ; c.url = 'http://example.com' ; c.http(:get)"
-e:1: [BUG] Segmentation fault
ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux]

-- control frame ----------
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC  :http
c:0003 p:0047 s:0007 b:0007 l:001b18 d:002270 EVAL   -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001b18 d:001b18 TOP   
---------------------------
-- Ruby level backtrace information-----------------------------------------
-e:1:in `http'
-e:1:in `<main>'

-- C level backtrace information -------------------------------------------
0x7f2816e4cd01 /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(rb_vm_bugreport+0x51) [0x7f2816e4cd01]
0x7f2816d73fde /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(+0x50fde) [0x7f2816d73fde]
0x7f2816d74143 /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(rb_bug+0xb3) [0x7f2816d74143]
0x7f2816df6d55 /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(+0xd3d55) [0x7f2816df6d55]
0x7f2816b15c20 /lib/libpthread.so.0(+0xfc20) [0x7f2816b15c20]
0x7f281541aa80 /home/phiggins/.rvm/gems/ruby-1.9.1-p378/gems/curb-0.7.7.1/lib/curb_core.so(+0x9a80) [0x7f281541aa80]
0x7f2816e3afb2 /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(+0x117fb2) [0x7f2816e3afb2]
0x7f2816e46959 /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(+0x123959) [0x7f2816e46959]
0x7f2816e410f0 /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(+0x11e0f0) [0x7f2816e410f0]
0x7f2816e4430f /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(+0x12130f) [0x7f2816e4430f]
0x7f2816e44531 /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(rb_iseq_eval_main+0xb1) [0x7f2816e44531]
0x7f2816d7635c /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(ruby_exec_node+0xac) [0x7f2816d7635c]
0x7f2816d779d7 /home/phiggins/.rvm/rubies/ruby-1.9.1-p378/lib/libruby.so.1.9(ruby_run_node+0x37) [0x7f2816d779d7]
0x400a1b ruby(main+0x4b) [0x400a1b]
0x7f2815ed7d2d /lib/libc.so.6(__libc_start_main+0xfd) [0x7f2815ed7d2d]
0x400909 ruby() [0x400909]

[NOTE]
You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted

installation on OS X

Maybe curb isn't exporting symbols properly for OS X?

macbook-pro:project user$ sudo rake gems:install
(in /Users/user/project)
** Erubis 2.6.5
gem install curb --version ">= 0.5.8.0" --source http://gemcutter.org
Building native extensions.  This could take a while...
Successfully installed curb-0.5.8.0
1 gem installed
Installing ri documentation for curb-0.5.8.0...
Installing RDoc documentation for curb-0.5.8.0...
macbook-pro:project user$ script/server 
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.2.3 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
dlsym(0x14317c0, Init_curb_core): symbol not found - /Library/Ruby/Gems/1.8/gems/curb-0.5.8.0/lib/curb_core.bundle
/Library/Ruby/Gems/1.8/gems/curb-0.5.8.0/lib/curb_core.bundle
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/curb-0.5.8.0/lib/curb.rb:1
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/rails/gem_dependency.rb:95:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:281:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:281:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:281:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:159:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:112:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:112:in `run'
/Users/user/project/config/environment.rb:26
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:147:in `rails'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:113:in `cloaker_'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:149:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:149:in `listener'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:99:in `cloaker_'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:50:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:50:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:84:in `new'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:84:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/command.rb:212:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:142:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:142:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/commands/servers/mongrel.rb:64
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/commands/server.rb:49
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
** Erubis 2.6.5
dlsym(0x16d1b60, Init_curb_core): symbol not found - /Library/Ruby/Gems/1.8/gems/curb-0.5.8.0/lib/curb_core.bundle
/Library/Ruby/Gems/1.8/gems/curb-0.5.8.0/lib/curb_core.bundle
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/curb-0.5.8.0/lib/curb.rb:1
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/rails/gem_dependency.rb:95:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:281:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:281:in `each'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:281:in `load_gems'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:164:in `process'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:112:in `send'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/initializer.rb:112:in `run'
/Users/user/project/config/environment.rb:26
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:147:in `rails'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:113:in `cloaker_'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:149:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:149:in `listener'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:99:in `cloaker_'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:50:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:50:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:84:in `new'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:84:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/command.rb:212:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:142:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:142:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/commands/servers/mongrel.rb:64
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.2.3/lib/commands/server.rb:49
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
Missing these required gems:
  curb  >= 0.5.8.0

You're running:
  ruby 1.8.6.287 at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  rubygems 1.3.4 at /Users/user/.gem/ruby/1.8, /Library/Ruby/Gems/1.8, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.
Exiting

PostFields.file generates exception in irb (or anytime .to_s) is called

Example:

irb(main):001:0> require 'curb'
=> true
irb(main):002:0> f=Curl::PostField.file('name','sdf');
irb(main):003:0* f.to_s
Curl::Err::InvalidPostFieldError: Local file and remote file are both nil curb_postfield.c:474
from (irb):3:in `to_s'
from (irb):3

This is causing all sorts of havoc when playing with Curb-related code on the console, logging data or for experimentation. I don't really know what the issue is.

Curl::Easy#timeout is not the usual kind of timeout and is useless for large transfers

Curl::Easy#timeout is a restriction on how long the entire transfer may take, not each network read. This is documented:

"Set the maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time and limiting operations to less than a few minutes risk aborting perfectly normal operations. "

The "transfer operation" here is a call to Curl::Easy#perform, not each individual network read call. When dealing with large transfers (>10 mb over Internet) there are no sensible timeout values: anything small actually aborts transfers due to "timeout" while data is being actively transferred, anything large causes code to wait unacceptably long to time out dead connections, and once transfer sizes reach into hundreds of megabytes the timeouts that would not abort legitimately working transfers over Internet start measuring in hours.

Curl has two options which, while oddly named, together are precisely equal to what most people call the timeout: CURLOPT_LOW_SPEED_TIME and CURLOPT_LOW_SPEED_LIMIT, specifically setting the time to the desired timeout and the limit to 1 would achieve desired effect. (http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)

Frustratingly, it seems that curb does not expose curl_easy_setopt call, making it currently at all impossible to set the above options.

Curl 0.7.7 does not compile well on EY

Not sure if this is an EY-specific issue or if lots of Linux systems will have the issue. I just lost a good hour trying to figure out why some worker processes were crashing, so I figured I would make a note.

Curl 0.7.7 seems to compile (gem install) ok, but will not run. This is what I get when I require it:

LoadError: /usr/lib/ruby/gems/1.8/gems/curb-0.7.7-x86-linux/ext/curb_core.so: ELF file OS ABI invalid - /usr/lib/ruby/gems/1.8/gems/curb-0.7.7-x86-linux/ext/curb_core.so
from /usr/lib/ruby/gems/1.8/gems/curb-0.7.7-x86-linux/ext/curb_core.so
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from /usr/lib/ruby/gems/1.8/gems/curb-0.7.7-x86-linux/lib/curb.rb:1 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:ingem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):2

0.7.6 works just fine.

HEAD followed by PUT on the same url results in 2 HEAD requests

I found this tonight when debugging a library we have, it does a 'ping' using a HEAD request against a server to make sure it is up, and then starts doing PUT's to store data. If we resuse the Curl::Easy object for both the HEAD and the PUT then the PUT ends up as a HEAD request.

http://gist.github.com/151800

If you do a HEAD followed by a GET on the same url, you get a HEAD followed by a GET.

I'll attempted to dig in on this a bit. But I'm not sure I'll be able to solve it.

curb.h shouldn't redefine RHASH_LEN if it is defined

Rubinius isn't able to provide RHASH() because it exposes a raw st*, but we can provide RHASH_LEN() to report the size of a hash. If curb only defines RHASH_LEN if it doesn't exist, then curb can compile under Rubinius.

error while trying to install in Mac OS 10.6.4

i get this error:


make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -DRUBY_EXTCONF_H=\"curb_config.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -I/opt/local/include -g -Wall  -c curb.c
In file included from /opt/local/include/curl/curl.h:35,
                 from curb.h:12,
                 from curb.c:8:
/opt/local/include/curl/curlrules.h:143: error: size of array ‘__curl_rule_01__’ is negative
/opt/local/include/curl/curlrules.h:153: error: size of array ‘__curl_rule_02__’ is negative
lipo: can't open input file: /var/tmp//ccUBr8sC.out (No such file or directory)
make: *** [curb.o] Error 1

I have installed curl thru macports, and i really dont have any idea what are the issues here. Please help..

Mac Snow Leopard error when using: require 'curb'

This has consumed hours of my time.

in the console i run: require 'curb'

i get the error:

LoadError: dlopen(/usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle, 9): no suitable image found. Did find:
/usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle: mach-o, but wrong architecture - /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle
from /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from /Users/user/Sites/CSG/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:inrequire'
from /Users/user/Sites/CSG/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' from /Users/user/Sites/CSG/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:inrequire'
from /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire'
from /Users/user/Sites/CSG/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require' from /Users/user/Sites/CSG/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:innew_constants_in'
from /Users/user/Sites/CSG/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
from ./lib/tokbox/base_api.rb:7

I have tried uninstalling the gem and reinstalling a number of versions with ARCHFLAGS="-arch i386"
No errors or warnings are given in the install
When i try and install with: rake install
I get this error as well.

I am working on a mac ox 10.6 with ruby 1.8

i notice there are libcurl.4.dylib, libcurl.3.dylib, and libcurl.2.dlib and libcurl.dylib in my /usr/lib folder...

I did an install of the newest 7.20 curl package.

Suggestions?

Segmentation fault on nil payload

Segmentation fault on nil payload on put method:
Ruby: 1.8.7
Curb: 0.7.7.1

Error:
[BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

Sample Code:

require 'rubygems'
require 'curb'

uri = "http://127.0.0.1:5984/testdb"
payload = nil

c = Curl::Easy.new
c.url = uri
c.http_put(payload)

Bus Error multi-handle teardown?

Quick way to reproduce

irb: require 'curb'
irb: multi = Curl::Multi.new
irb: exit
<main>:47140: [BUG] Bus Error
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9]

-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:001b44 d:001b44 TOP    <main>:47140
---------------------------
-- Ruby level backtrace information-----------------------------------------

-- C level backtrace information -------------------------------------------
0x2f8e42 0   libruby.dylib                       0x002f8e42 rb_vm_bugreport + 82
0x20de7c 1   libruby.dylib                       0x0020de7c rb_warning + 444
0x20dedb 2   libruby.dylib                       0x0020dedb rb_bug + 43
0x29f17b 3   libruby.dylib                       0x0029f17b rb_enable_interrupt + 75
0x93c072bb 4   libSystem.B.dylib                   0x93c072bb _sigtramp + 43
0xffffffff 5   ???                                 0xffffffff 0x0 + 4294967295
0x2205da 6   libruby.dylib                       0x002205da rb_obj_id + 250
0x220742 7   libruby.dylib                       0x00220742 rb_obj_id + 610
0x2209ac 8   libruby.dylib                       0x002209ac rb_gc_call_finalizer_at_exit + 412
0x2134c2 9   libruby.dylib                       0x002134c2 ruby_cleanup + 258
0x213646 10  libruby.dylib                       0x00213646 ruby_run_node + 102
0x1fef 11  ruby                                0x00001fef main + 95
0x1f56 12  ruby                                0x00001f56 start + 54

I'm running ruby-1.9.1p129 on OS X - installed via MacPorts

[Multi] "select(): Bad file descriptor" on a terminated socket

I'm working on steps to reproduce, but here's what I'm seeing:

I make a request to a server (in this case, Amazon SimpleDB), and it returns a 500 while terminating the socket. The next time I run curl multi perform, I get a "select(): Bad file descriptor" exception. I'm surprised that curl doesn't pull it out of the file descriptor set, though

Note that the way I'm currently using the multi interface is to have a thread constantly hitting multi.perform (when it knows there's work to do) - this may be not an intended use, too :P

Source is here: http://github.com/safis/util/blob/bb8394a6cc19306d97a14561b5362281f66d4c70/lib/safis/util/requester.rb

304 response status codes trigger the on_failure block

Greetings. I have been implementing an app that uses caching and I am setting the if-modified-since header to test if the response code is 200 or 304.

For some reason when it returns 304 status code response, it never calls the on_success block. Instead it calls both the on_complete and on_failure blocks.

Is this the desired action for 304 responses?

Here is an example of the code I am using.

#!/usr/bin/env ruby

require 'rubygems'
require 'curb'
require 'uri'

# Define URL
url = "http://www.google.com/intl/en_ALL/images/logo.gif"
easy = Curl::Easy.new URI.escape(url) do |curl|
  # Set header for cache
  curl.headers['If-Modified-Since'] = "Wed, 07 Jun 2006 19:38:24 GMT"
  curl.headers['Cache-Control'] = "max-age=0"

  # On successful download (ie a response was returned from the web server)
  curl.on_success do |response|
    print "We have success.  The response code is #{response.response_code}\n"
  end
  curl.on_complete do |response|
    print "We have complete.  The response code is #{response.response_code}\n"
  end

  curl.on_failure do |response, err|
    print "We have failure.  The response code is #{response.response_code}\n"
    print "Error is: #{err.inspect}\n"
  end
end

easy.verbose = true
easy.perform

The output:

* About to connect() to www.google.com port 80 (#0)
*   Trying 74.125.157.104... * Connected to www.google.com (74.125.157.104) port 80 (#0)
> GET /intl/en_ALL/images/logo.gif HTTP/1.1
Host: www.google.com
Accept: */*
If-Modified-Since: Wed, 07 Jun 2006 19:38:24 GMT
Cache-Control: max-age=0

< HTTP/1.1 304 Not Modified
< Last-Modified: Wed, 07 Jun 2006 19:38:24 GMT
< X-Content-Type-Options: nosniff
< Date: Mon, 02 Nov 2009 15:34:55 GMT
< Server: gws
< X-XSS-Protection: 0
< 
* Expire cleared
* Connection #0 to host www.google.com left intact
We have complete.  The response code is 304
We have failure.  The response code is 304
Error is: [Curl::Err::CurlError, "Unknown error result from libcurl"]

I looked in the C code to see where that error gets set and it looks like it is the default code if no other curl error codes match. Why are 304 responses returning an error code from Curl?

Just as an aside, if I don't set caching headers, here is the 200 response

* About to connect() to www.google.com port 80 (#0)
*   Trying 74.125.157.103... * Connected to www.google.com (74.125.157.103) port 80 (#0)
> GET /intl/en_ALL/images/logo.gif HTTP/1.1
Host: www.google.com
Accept: */*

< HTTP/1.1 200 OK
< Content-Type: image/gif
< Last-Modified: Wed, 07 Jun 2006 19:38:24 GMT
< Date: Mon, 02 Nov 2009 15:33:53 GMT
< Expires: Tue, 02 Nov 2010 15:33:53 GMT
< X-Content-Type-Options: nosniff
< Server: gws
< Content-Length: 8558
< Cache-Control: public, max-age=31536000
< Age: 85
< X-XSS-Protection: 0
< 
* Expire cleared
* Connection #0 to host www.google.com left intact
We have complete.  The response code is 200
We have success.  The response code is 200

Any ideas?

Thanks,
Wes

Implement CURLINFO_COOKIELIST get

I noticed there is a TODO comment in curb_easy.c to implement this function. Is anyone working on it already? If not I could probably take a crack at it but my C is a little rusty.

Do not build on OS X Snow Leopard

$ sudo gem install curb
Building native extensions.  This could take a while...
ERROR: Error installing curb:
ERROR: Failed to build gem native extension.
make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -DRUBY_EXTCONF_H=\"curb_config.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -I/opt/local/include -Wall  -c curb.c
In file included from /opt/local/include/curl/curl.h:36,
                 from curb.h:12,
                 from curb.c:8:
/opt/local/include/curl/curlrules.h:144: error: size of array ‘__curl_rule_01__’ is negative
/opt/local/include/curl/curlrules.h:154: error: size of array ‘__curl_rule_02__’ is negative
lipo: can't open input file: /var/tmp//ccgPJWIG.out (No such file or directory)
make: *** [curb.o] Error 1

This works:

$ sudo env ARCHFLAGS="-arch x86_64" gem install curb
Building native extensions.  This could take a while...
Successfully installed curb-0.5.4.0

Curb does not seem to perform persistent connections

If I run:
curl http://localhost/~drbrain/zeros-1k http://localhost/~drbrain/zeros-1k

Under strace on FreeBSD I can see it perform two sendo()/recvfrom() on a single socket without closing it in between
(trimmed):

socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP) = 3
connect(3, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...}, 28) = 0
sendto(3, "GET /~drbrain/zeros-1k HTTP/1.1\r\n"..., 169, MSG_NOSIGNAL, NULL, 0) = 169
recvfrom(3, "HTTP/1.1 200 OK\r\nDate: Fri, 07 Ma"..., 16384, 0, NULL, NULL) = 1296
[...]
sendto(3, "GET /~drbrain/zeros-1k HTTP/1.1\r\n"..., 169, MSG_NOSIGNAL, NULL, 0) = 169
recvfrom(3, "HTTP/1.1 200 OK\r\nDate: Fri, 07 Ma"..., 16384, 0, NULL, NULL) = 1296

When I perform what should be the equivalent ruby code I see two sockets created and closed:

require 'rubygems'
require 'curb'

N = (ARGV.shift || 50).to_i

c = Curl::Easy.new 'http://127.0.0.1/~drbrain/zeros-2k'
N.times do
c.perform
end

running this with 2 (trimmed):

socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
connect(3, {sa_family=0x69 /* AF_??? /, sa_data="/../../crypto/"...}, 16) = 0
sendto(3, "GET /~drbrain/zeros-2k HTTP/1.1\r\n"..., 65, MSG_NOSIGNAL, NULL, 0) = 65
recvfrom(3, "HTTP/1.1 200 OK\r\nDate: Fri, 07 Ma"..., 16384, 0, NULL, NULL) = 2320
[...]
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
connect(4, {sa_family=0x32 /
AF_??? */, sa_data=" Apache/2.2.13"...}, 16) = 0
sendto(4, "GET /~drbrain/zeros-2k HTTP/1.1\r\n"..., 65, MSG_NOSIGNAL, NULL, 0) = 65
recvfrom(4, "HTTP/1.1 200 OK\r\nDate: Fri, 07 Ma"..., 16384, 0, NULL, NULL) = 2320

Can't tell Curl to use a cookiefile (CURLOPT_COOKIEFILE)

There seems to be no way to set the CURLOPT_COOKIEFILE option in Curb, which wasn't a problem for me until I couldn't get a HTTP POST to re-use the cookies from an earlier request.

After some digging at http://curl.haxx.se/docs/httpscripting.html, I see that you can do this with the curl binary: curl -b cookies-to-send.txt -c store-cookies-here.txt www.cookiesite.com

The libcurl docs (http://curl.haxx.se/libcurl/c/curl_easy_setopt.html) say that CURLOPT_COOKIEFILE is the option I'm looking for so I added this to Curb in my fork - see commit http://github.com/chuyeow/curb/commit/99c71de50e1106a99244f09b5d4dbdee4febcddc

This solved my problem with the HTTP POST not re-using cookies.

Hope I got the patch right, thanks!

Install Error on Snow Leopard

I cannot install on snow leopard.

I get the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing curb:
        ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
"-arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common $(cflags)"
checking for curl-config... yes
checking for curlinfo_redirect_time... no
checking for curlinfo_response_code... no
checking for curlinfo_filetime... no
checking for curlinfo_redirect_count... no
checking for curlinfo_os_errno... no
checking for curlinfo_num_connects... no
checking for curlinfo_ftp_entry_path... no
checking for curl_version_ssl... no
checking for curl_version_libz... no
checking for curl_version_ntlm... no
checking for curl_version_gssnegotiate... no
checking for curl_version_debug... no
checking for curl_version_asynchdns... no
checking for curl_version_spnego... no
checking for curl_version_largefile... no
checking for curl_version_idn... no
checking for curl_version_sspi... no
checking for curl_version_conv... no
checking for curlproxy_http... no
checking for curlproxy_socks4... no
checking for curlproxy_socks5... no
checking for curlauth_basic... no
checking for curlauth_digest... no
checking for curlauth_gssnegotiate... no
checking for curlauth_ntlm... no
checking for curlauth_anysafe... no
checking for curlauth_any... no
checking for curle_tftp_notfound... no
checking for curle_tftp_perm... no
checking for curle_tftp_diskfull... no
checking for curle_tftp_illegal... no
checking for curle_tftp_unknownid... no
checking for curle_tftp_exists... no
checking for curle_tftp_nosuchuser... no
checking for curle_send_fail_rewind... no
checking for curle_ssl_engine_initfailed... no
checking for curle_login_denied... no
checking for curlmopt_maxconnects... no
checking for curle_conv_failed... no
checking for curle_conv_reqd... no
checking for curle_ssl_cacert_badfile... no
checking for curle_remote_file_not_found... no
checking for curle_ssh... no
checking for curle_ssl_shutdown_failed... no
checking for curle_again... no
checking for curle_ssl_crl_badfile... no
checking for curle_ssl_issuer_error... no
checking for curlopt_username... no
checking for curlopt_password... no
checking for curlinfo_primary_ip... no
checking for curlauth_digest_ie... no
checking for curlm_bad_socket... no
checking for curlm_unknown_option... no
checking for curl_multi_timeout()... no
checking for curl_multi_fdset()... no
checking for curl_multi_perform()... no
checking for Ruby 1.9 Hash... no
checking for Ruby 1.9 st.h... yes
checking for curl_easy_escape... no
creating curb_config.h
creating Makefile

make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -DRUBY_EXTCONF_H=\"curb_config.h\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -I/usr/local/include -g -Wall  -c curb.c
In file included from /usr/local/include/curl/curl.h:36,
                 from curb.h:12,
                 from curb.c:8:
/usr/local/include/curl/curlrules.h:134: error: size of array ‘__curl_rule_01__’ is negative
/usr/local/include/curl/curlrules.h:144: error: size of array ‘__curl_rule_02__’ is negative
lipo: can't open input file: /var/tmp//ccJHnOh5.out (No such file or directory)
make: *** [curb.o] Error 1

It installed fine on my leopard macbook earlier today.

Hope you can help.

Cheers,
Alastair

File exists but getting a Curl::Err::InvalidPostFieldErro

This code

    require 'rubygems'
    require 'curb'
    require 'fileutils'

    SERVER = 'http://localhost:3000'
    PROFILES_URL = SERVER+'/profiles'

    filename = '111minna-2.jpg'

    unless File.exists?(filename)
      puts "File does not exist"
      exit
    end

    put_data = []
    put_data << Curl::PostField.content('name', 'dav')
    put_data << Curl::PostField.file('file', filename) 

    c = Curl::Easy.new(PROFILES_URL)
    c.multipart_form_post = true
    c.http_put(put_data)

results in

    cant_post_file.rb:21:in `to_str': Local file and remote file are both nil curb_postfield.c:474 (Curl::Err::InvalidPostFieldError)
        from cant_post_file.rb:21:in `to_s'
        from cant_post_file.rb:21:in `perform'
        from cant_post_file.rb:21:in `http_put'
        from cant_post_file.rb:21

Cant get Crub working

sorry for being so short, this is what i get when i start my railsapp

Failed to load /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle
/usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' /Users/toh/src/rssvoice/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require'
/Users/toh/src/rssvoice/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in
new_constants_in' /Users/toh/src/rssvoice/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in require'
/usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb.rb:1
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
/Users/toh/src/rssvoice/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in
require' /Users/toh/src/rssvoice/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in'
/Users/toh/src/rssvoice/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in
require' /usr/local/lib/ruby/gems/1.8/gems/pauldix-feedzirra-0.0.18/lib/feedzirra.rb:6 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'

Critical:: Unable to remove easy from requests

I got this error, once, after running for quite a while. This is running 0.5.7.0 and using the re-adding functionality.

This code is exercised quite a bit, and I'm not sure how to reproduce it.

doesn't compile under rvm with ree on debian

Hi,

I installed rvm on a debian system and have a ruby enterprise edition environment created. Installing curb 0.1.4 works out of the box, newer versions get me a lot of linking errors see ( http://gist.github.com/457042). MRI in rvm looks good.

If I delete the link option "-Wl,-z,defs" everything links fine. Sorry, I don't know if this a system configuration issue or a gem configuration issue.

THX
Peter

cacert, cert password and useragent options

added code for these options to curb. do you prefer to have issues opened here or to get a pull request or something else?

I added code and tests for this stuff here: git://github.com/mobileAgent/curb.git

quick rubyforge documentation change

I was using Curb and having some issues with libcurl's default "Expect: 100" on POSTs. In order to fix this, I tried
easy.headers["Expect:"] = ''
as suggested in the documentation, however it should be
easy.headers["Expect"] = ''
(without the colon). Sorry if I'm being nitpicky; I just spent a while trying to figure out what the problem was, and I thought that other people benefiting from your library might be making the same mistakes as me.

Thanks for making a great library!
-Sam

Segfault using PostField.file with block

$ ruby crash_curb.rb 
crash_curb.rb:7: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]

Aborted

crash_curb.rb:
#!/usr/bin/ruby
require 'rubygems'
require 'curb'

curl = Curl::Easy.new('http://example.com/')
curl.multipart_form_post = true
curl.http_post(Curl::PostField.file('test', 'test.xml'){'example data'})

Ubuntu 9.10
curb gem version 0.6.2.1

curl human readable errors or symbols from on_failure ?

I'm using the on_failure callback, and the error codes are great, but I haven't seen a way to print something useful out with that error code. For instance if I have an unresolveable host, I just get 6 passed to on_failure. Is there a way to get the info from curl_easy_strerro?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.