Skip to content
An HTTP library for Ruby that takes advantage of everything HTTP has to offer.
Find file
Pull request Compare This branch is 12 commits ahead of pezra:master.
Latest commit d2fea39 @paul Merge pull request #1 from pezra/promiscuous-basic-auth
Promiscuous basic auth
Failed to load latest commit information.
lib implemented a promiscuous basic authenticator
spec implemented a promiscuous basic authenticator
.autotest Refactor redirects
.gitignore Modernize, clean up some bitrot
Gemfile Modernize, clean up some bitrot
History.txt updated history for promiscuous basic auth support
Manifest added new file to manifest
README.markdown Update readme with new convenience methods
Rakefile Modernize, clean up some bitrot
resourceful.gemspec Update gemspec



Resourceful provides a convenient Ruby API for making HTTP requests.


  • GET, PUT, POST and DELETE HTTP requests
  • HTTP Basic and Digest authentication
  • HTTP Caching with pluggable backends
  • Follow redirects based on the results of a callback

More Info


Getting started

gem install resourceful

Simplest example

require 'resourceful'
resp = Resourceful.get('')
puts resp.body

Get a page requiring HTTP Authentication

my_realm_authenticator ='My Realm', 'admin', 'secret')
http = => my_realm_authenticator)
resp = http.resource('').get
puts resp.body

Redirection based on callback results

Resourceful will by default follow redirects on read requests (GET and HEAD), but not for POST, etc. If you want to follow a redirect after a post, you will need to set the resource#on_redirect callback. If the callback evaluates to true, it will follow the redirect.

resource = http.resource('')
resource.on_redirect { |req, resp| resp.header['Location'] =~ / }
resource.get  # Will only follow the redirect if the new location is

Post a URL encoded form

 require 'resourceful'
 http =
 resp = http.resource('http://mysite.example/service').
          post( => 'test', :level => 'super'))

Post a Mulitpart form with a file

 require 'resourceful'
 http =
 form_data = => 'me')
 form_data.add_file('avatar', '/tmp/my_avatar.png', 'image/png')
 resp = http.resource('http://mysite.example/service').post(form_data)

Put an XML document

 require 'resourceful'
 http =
 resp = http.resource('http://mysite.example/service').
          put('<?xml version="1.0"?><test/>', :content_type => 'application/xml')

Delete a resource

 require 'resourceful'
 http =
 resp = http.resource('http://mysite.example/service').delete


Copyright (c) 2008 Absolute Performance, Inc, Peter Williams. Released under the MIT License.

Something went wrong with that request. Please try again.