Skip to content
This repository

Ruby HTTP client based on libcurl

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 ext
Octocat-spinner-32 lib
Octocat-spinner-32 script
Octocat-spinner-32 spec
Octocat-spinner-32 .autotest For some reason autotest wasn't catching changes properly.
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE Added license file.
Octocat-spinner-32 README.txt
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION.yml
Octocat-spinner-32 patron.gemspec
= Ruby HTTP Client


Patron is a Ruby HTTP client library based on libcurl. It does not try to expose
the full "power" (read complexity) of libcurl but instead tries to provide a
sane API while taking advantage of libcurl under the hood.


Usage is very simple. First, you instantiate a Session object. You can set a few
default options on the Session instance that will be used by all subsequent

    sess =
    sess.timeout = 10
    sess.base_url = ""
    sess.headers['User-Agent'] = 'myapp/1.0'

The Session is used to make HTTP requests.

    resp = sess.get("/foo/bar")

Requests return a Response object:

    if resp.status < 400
      puts resp.body

The GET, HEAD, PUT, POST and DELETE operations are all supported.

    sess.put("/foo/baz", "some data")

You can ship custom headers with a single request:"/foo/stuff", "some data", {"Content-Type" => "text/plain"})

That is pretty much all there is to it.


You need a recent version of libcurl in order to install this gem. On MacOS X
the provided libcurl is sufficient. You will have to install the libcurl
development packages on Debian or Ubuntu. Other Linux systems are probably
similar. Windows users are on your own. Good luck with that.


  sudo gem install patron

Copyright (c) 2008 The Hive
Something went wrong with that request. Please try again.