Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtblin/http_mini
A truly minimalist Http client for Ruby
https://github.com/jtblin/http_mini
Last synced: 19 days ago
JSON representation
A truly minimalist Http client for Ruby
- Host: GitHub
- URL: https://github.com/jtblin/http_mini
- Owner: jtblin
- License: bsd-3-clause
- Created: 2013-07-22T12:35:53.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-07T08:50:10.000Z (almost 10 years ago)
- Last Synced: 2024-04-25T08:21:05.774Z (8 months ago)
- Language: Ruby
- Size: 192 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Http mini
[![Gem Version](https://badge.fury.io/rb/http_mini.png)](http://badge.fury.io/rb/http_mini)
[![Build Status](https://travis-ci.org/jtblin/http_mini.png)](https://travis-ci.org/jtblin/http_mini)
[![Coverage Status](https://coveralls.io/repos/jtblin/http_mini/badge.png?branch=master)](https://coveralls.io/r/jtblin/http_mini?branch=master)
[![Code Climate](https://codeclimate.com/github/jtblin/http_mini.png)](https://codeclimate.com/github/jtblin/http_mini)A truly minimalist Http client for Ruby. When all you want is
a one liner to ping or get the response from a web server.## Install
gem install http_mini --no-ri --no-rdoc
## Usage
# Sometimes you just need to know if the site is up and running
do_something if HttpMini.new('http://www.acme.com').poke# or you want to get the status code
puts HttpMini.new('http://www.google.com').head.code# You can also set values for timeouts.
puts HttpMini.new('http://www.google.com', {read_timeout: 3, open_timeout: 5}).get.body#You can change the url and chain calls
http = HttpMini.new('www.apple.com')
apple_html = http.get.body
ruby_html = http.uri('http://www.ruby-lang.org/en/').get.body# or just the path
http_request_html = http.path('/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTPRequest.html').get.body# Set http headers
puts HttpMini.new('http://www.google.com', headers: {'user-agent' => 'Fancy UserAgent Name'}).head.code# Basic auth
puts HttpMini.new('http://foo:[email protected]').head.code## HTTP verbs Support
* HEAD
* GET
* POST
* PUT
* DELETE
* OPTIONS## Request options
* `:headers` - http headers, defaults to {}
* `:timeout` - number of seconds to wait for the connection to open, number of seconds to wait for one block to be read
* `:ignore_error` - ignore errors on poke, defaults to `true`
* `:unsafe` - ignore SSL errors, defaults to `false` except for poke## Author
Jerome Touffe-Blin, [@jtblin](https://twitter.com/jtlbin), [http://www.linkedin.com/in/jtblin](http://www.linkedin.com/in/jtblin)
## License
HttpMini is copyright 2013 Jerome Touffe-Blin and contributors. It is licensed under the BSD license.
See the include LICENSE file for details.