Http 0.3.0: a simple way to talk to the web

The Http gem uses a simple, chainable syntax to build complex HTTP
requests:

Want to make a request and obtain the response as a string?

Http.get "http://www.google.com"

That’s it! The result is the response body.

Making POST requests is simple too. Want to POST a form?

Http.post "http://example.com/resource", :form => {:foo => "42"}

Want to POST with a specific body, JSON for instance?

Http.post "http://example.com/resource", :body => JSON.dump(:foo => 

‘42’)

Or have it automatically serialize for you:

Http.post "http://example.com/resource", :json => {:foo => '42'}

It’s easy!


Version 0.3.0 is practically a complete rewrite of the core internals.
Whereas previous versions were simply a wrapper for Net::HTTP, this
release is rewritten around the http_parser.rb library and provides
its own HTTP client logic.

Full changelog follows:

  • New implementation based on tmm1’s http_parser.rb instead of Net::HTTP
  • Support for following redirects
  • Support for request body through {:body => …} option
  • Http#with_response (through Chainable)