Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A HTTP client library written from scratch, offering an easy interface with lots of flexibility

tree: 5f911324ef
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.

Something went wrong with that request. Please try again.