Permalink
Browse files

initial commit with multi handle support

  • Loading branch information...
0 parents commit 43356d6bfc049665d352303bb444f4624f2ae43f @taf2 committed Jul 15, 2008
@@ -0,0 +1,51 @@
+Copyright (c) 2006 Ross Bamford (rosco AT roscopeco DOT co DOT uk).
+Curb is free software licensed under the following terms:
+
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
+
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
+
+ b) use the modified software only within your corporation or
+ organization.
+
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 3. You may distribute the software in object code or binary form,
+ provided that you do at least ONE of the following:
+
+ a) distribute the binaries and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
+
+ b) accompany the distribution with the machine-readable source of
+ the software.
+
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial).
+
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
+
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
@@ -0,0 +1,128 @@
+== Curb - Libcurl bindings for Ruby
+
+* http://curb.rubyforge.org/
+* http://rubyforge.org/projects/curb
+
+Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the
+libcurl(3), a fully-featured client-side URL transfer library.
+cURL and libcurl live at http://curl.haxx.se/ .
+
+Curb is a work-in-progress, and currently only supports libcurl's 'easy' mode.
+
+=== License
+
+Curb is copyright (c)2006 Ross Bamford, and released under the terms of the
+Ruby license. See the LICENSE file for the gory details.
+
+=== You will need
+
+* A working Ruby installation (1.8+, tested with 1.8.5)
+* A working (lib)curl installation, with development stuff (7.5+, tested with 7.15)
+* A sane build environment
+
+=== Installation...
+
+... will usually be as simple as:
+
+ $ gem install curb
+
+Or, if you downloaded the archive:
+
+ $ rake install
+
+If you have a wierd setup, you might need extconf options. In this case, pass
+them like so:
+
+ $ rake install EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever'
+
+Currently, Curb is tested only on GNU/Linux x86 - YMMV on other platforms.
+If you do use another platform and experience problems, or if you can
+expand on the above instructions, please get in touch via the mailing
+list on Curb's Rubyforge page.
+
+Curb has fairly extensive RDoc comments in the source. You can build the
+documentation with:
+
+ $ rake doc
+
+=== Examples
+
+Simple fetch via HTTP:
+
+ c = Curl::Easy.perform("http://www.google.co.uk")
+ puts c.body_str
+
+Same thing, more manual:
+
+ c = Curl::Easy.new("http://www.google.co.uk")
+ c.perform
+ puts c.body_str
+
+Additional config:
+
+ Curl::Easy.perform("http://www.google.co.uk") do |curl|
+ curl.headers["User-Agent"] = "myapp-0.0"
+ curl.verbose = true
+ end
+
+Same thing, more manual:
+
+ c = Curl::Easy.new("http://www.google.co.uk") do |curl|
+ curl.headers["User-Agent"] = "myapp-0.0"
+ curl.verbose = true
+ end
+
+ c.perform
+
+Supplying custom handlers:
+
+ c = Curl::Easy.new("http://www.google.co.uk")
+
+ c.on_body { |data| print(data) }
+ c.on_header { |data| print(data) }
+
+ c.perform
+
+Reusing Curls:
+
+ c = Curl::Easy.new
+
+ ["http://www.google.co.uk", "http://www.ruby-lang.org/"].map do |url|
+ c.url = url
+ c.perform
+ c.body_str
+ end
+
+HTTP POST form:
+
+ c = Curl::Easy.http_post("http://my.rails.box/thing/create",
+ Curl::PostField.content('thing[name]', 'box',
+ Curl::PostField.content('thing[type]', 'storage')
+
+HTTP POST file upload:
+
+ c = Curl::Easy.new("http://my.rails.box/files/upload")
+ c.multipart_form_post = true
+ c.http_post(Curl::PostField.file('myfile.rb'))
+
+Multi Interface:
+ responses = {}
+ requests = ["http://www.google.co.uk/", "http://www.ruby-lang.org/"]
+ m = Curl::Multi.new
+ # add a few easy handles
+ requests.each do |url|
+ responses[url] = ""
+ c = Curl::Easy.new(url) do|curl|
+ curl.follow_location = true
+ curl.on_body{|data| responses[url] << data; data.size }
+ end
+ m.add(c)
+ end
+
+ m.perform do
+ puts "idling... can do some work here, including add new requests"
+ end
+
+ requests.each do|url|
+ puts responses[url]
+ end
Oops, something went wrong. Retry.

2 comments on commit 43356d6

@sporkmonger

On Ubuntu:

make
Makefile:129: warning: overriding commands for target `/usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.2.4/ext'
Makefile:127: warning: ignoring old commands for target `/usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.2.4/ext'
gcc -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DRUBY_EXTCONF_H=\"curb_config.h\"  -fPIC -g -O2 -I/usr/local/include -Wall  -c curb.c
gcc -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DRUBY_EXTCONF_H=\"curb_config.h\"  -fPIC -g -O2 -I/usr/local/include -Wall  -c curb_easy.c
gcc -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DRUBY_EXTCONF_H=\"curb_config.h\"  -fPIC -g -O2 -I/usr/local/include -Wall  -c curb_errors.c
gcc -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DRUBY_EXTCONF_H=\"curb_config.h\"  -fPIC -g -O2 -I/usr/local/include -Wall  -c curb_multi.c
curb_multi.c: In function 'rb_curl_multi_read_info':
curb_multi.c:177: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DRUBY_EXTCONF_H=\"curb_config.h\"  -fPIC -g -O2 -I/usr/local/include -Wall  -c curb_postfield.c
gcc -shared -rdynamic -Wl,-export-dynamic   -L'/usr/local/lib' -Wl,-R'/usr/local/lib' -o curb_core.so curb.o curb_easy.o curb_errors.o curb_multi.o curb_postfield.o  -lpthread -ldl -lcrypt -lm   -lc -L/usr/local/lib -lcurl -lidn -lssl -lcrypto -ldl -lz
/usr/bin/ld: /usr/local/lib/libz.a(deflate.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [curb_core.so] Error 1


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.2.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.2.4/ext/gem_make.out
@taf2
Owner
taf2 commented on 43356d6 Feb 7, 2009

Try the newer gem 0.2.7 has a fix for debian’s install script.

Please sign in to comment.