Project

hypetext

0.0
No commit activity in last 3 years
No release in over 3 years
A gem that provides a simple and dirty HTTP client that handles get, post, and automatic SSL
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

HypeText

The simple dirty http client library for ruby

Gem Version Build Status

$ gem install hypetext

###Using HypeText

require 'hypetext'
@client = HypeText.new
google = @client.get_by_url("http://www.google.com")
puts google[:body]
require 'hypetext'
@client = HypeText.new
post = @client.post_by_url("http://www.google.com", {:params=>{"key"=>"value"}})
puts post[:response].code

###Get and Post methods

@client.get_by_url("url string", {options hash})
@client.post_by_url("url string", {parameters hash}, {options hash})

##Advanced HypeText

You can pass in a default client timeout or turn off ssl cert verification

@client = HypeText.new({:timeout=>10, :ssl_verify=>false})

(All requests will time out after 10 seconds and raise a HypeTextExecption::TimeoutError)

You can define a custom RootCA

@client = HypeText.new({:rootCA=>"/my/custom/cert.ca", :ssl_verify=>true})

You can add params to a get or post using a hash

@client.get_by_url("http://example.com", {"key"=>"value"})
@client.post_by_url("http://example.com", {"key"=>"value"})

You can add custom headers (like cookies)

@client.get_by_url("http://example.com", {:parameter=>{"key"=>"value"}, :headers=>{"cookies"=>"my_cookie_string"}})
@client.get_by_url("http://example.com",{:headers=>{"cookies"=>"my_cookie_string"}})
@client.post_by_url("http://example.com", {"key"=>"value"}, {:headers=>{"cookies"=>"my_cookie_string"}})

You can even override the client's timeout for a specific call

@client.get_by_url("http://example.com", {:timeout=>1})
@client.get_by_url("http://example.com", {:parameter=>{"key"=>"value"}, :headers=>{"cookies"=>"my_cookie_string"}, :timeout=>30})