Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An easy to remember interface to Net::HTTP

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 README.md
Octocat-spinner-32 plain_http.gemspec
README.md

plain_http

I always forget the API for Net:HTTP. This library wraps Net::HTTP and doesn't try to do anything too clever on top of that. PlainHTTP has 'get', 'post', 'put', and 'delete' methods. Call any of them with the full URL, followed by a hash of headers. In the case of 'post' and 'put' you can include a 3rd parameter which is the data to send along, it can be a string or a hash.

All of the calls return the built in Net:HTTPResponse objects.

Examples

GET

response = PlainHTTP.get('http://www.google.com')
puts response.body

POST with form params

response = PlainHTTP.post('http://example.com/test.php', {}, {:post_name => 'value'})
puts response.body

POST with string body

response = PlainHTTP.post('http://example.com/test.php', {}, '{"name":"Chris Cherry"}')
puts response.body
Something went wrong with that request. Please try again.