Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A simple HTTP client
Ruby
tree: b11c671ac5

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.textile
http.rb

README.textile

Introduction

A simple Net::HTTP based HTTP client that supports:

  • POST/GET
  • SSL/HTTPs
  • proxies
  • debugging
  • redirect handling
  • headers
  • connect and read timeout
  • detection of response encoding

Usage

  
headers = {
  "User-Agent" => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; sv-SE; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13",
  "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
# GET
response = HTTP.get(url, :headers => headers)
# POST
response = HTTP.post(url, :parameters => {:a => :b}, :headers => headers)
# Detect encoding
encoding = HTTP.encoding(response)
  
Something went wrong with that request. Please try again.