Project

righttp

0.0
No commit activity in last 3 years
No release in over 3 years
A HTTP client library written from scratch that is easy to use and offers full flexibility
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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.