Sha256: 58e7e64588f579dcf6bc6a26c42cdad2be0d1ff120ca198959e39ee71b431a08

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

= net_helper

Provides a wrapper around HTTP GET requests. Uses Net::HTTP (under RestClient) by default, but will use Typhoeus if available
Will return the raw body (unparsed) for each request.

== Usage
Rails2
  gem.config 'itrigga-net_helper', :lib => 'net_helper'

Rails3 (bundler)
  gem 'itrigga-net_helper', :require => 'net_helper'

=== Basic example
  Itrigga::NetHelper.get :url => "http://www.google.com"

=== Adding params
  Itrigga::NetHelper.get :url => "http://www.google.com", :params => {:p1 => "123"}
Gives url http://www.google.com?p1=123

=== Variables

timeout - in seconds (default 5)
retries_on_timeout - how many times to try again (default 5)
max_redirects - number of redirects to follow (default 3)

The SystemTimer gem will be used for timeout is available.

  Itrigga::NetHelper.get :url => "http://www.google.com", :timeout => 300, :max_redirects => 1

== Using Typhoeus
The Typhoeus gem needs to be installed (see https://github.com/dbalatero/typhoeus)
Rails2 - gem.config 'typhoeus'
Rails3 - gem 'typhoeus'

To enable for all requests set the constant ITNH_HTTP_ENGINE = "Typhoeus"
To use on a per request basis

  Itrigga::NetHelper.get :url => "http://www.google.com", :http_engine => "Typhoeus"

== Contributing to net_helper
 
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2011 Al Davidson. See LICENSE.txt for
further details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itrigga-net_helper-0.3.0 README.rdoc