A HTTP client library written from scratch, offering an easy interface with lots of flexibility
Ruby
Failed to load latest commit information.
doc
lib splitted the send method and corrected body creation Mar 17, 2011
test
.document
.gitignore updated .gitignore Aug 11, 2010
LICENSE updated rakefile and license Jun 30, 2010
README.textile
Rakefile
VERSION
righttp.gemspec

README.textile

righttp

What righttp wants to achieve

righttp is intended to provide a simple and clean interface for HTTP requests while allowing to override almost every parameter of the request if it is neccessary.

It is not just a wrapper of net/http

Its philosophy is to get out of your way.

Below you can see the various ways to make a request:

Interface

HTTP.get( 'http://foobar.com' )

request   = HTTP.get( 'http://foobar.com?foo=bar&baz=bang')
response  = request.send

response  = HTTP.get( 'http://foobar.com:3000?foo=bar&baz=bang').send

request   = HTTP.get(
  'http://foobar.com',
  :body => {"foo" => "bar", :baz => "bang"}
)
response  = request.send

request   = HTTP.get(
  'http://foobar.com',
  :body => {"foo" => "bar", :baz => "bang"}
)
response  = request.send

request   = HTTP.get(
  :host   => 'foobar.com',
  :path   => "/posts",
  :port   => 3000
  :body   => {"foo" => "bar", :baz => "bang"},
)
response  = request.send

request   = HTTP.post( 'foobar.com', :body => {"foo" => "bar"} )
response  = request.send

request = HTTP.post(
  'foobar.com',
  :body => {"foo" => "bar", :attachment => File.open("path/to/file.jpg")}
)
response = request.send

request = Rig::HTTP.new(
  :host   => "example.org",
  :path   => "/posts",
  :body   => { "title" => "Oh Hai", "upload" => File.open("/path/to/file.jpg") }
)
response = request.send

The file will be closed once the multipart is created.

Responses

When a request is send it returns a Rig::HTTPResponse which has two attributes: status, header and body

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don’t break it in a
    future version unintentionally.
  • Commit, do not mess with rakefile, version, or history.
    (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2010 hukl. See LICENSE for details.