Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/savonrb/httpi

Common interface for Ruby's HTTP clients
https://github.com/savonrb/httpi

Last synced: 4 days ago
JSON representation

Common interface for Ruby's HTTP clients

Awesome Lists containing this project

README

        

# HTTPI

A common interface for Ruby's HTTP libraries. This project is now in maintenance mode. For new projects, we recommend [faraday](https://github.com/lostisland/faraday).

[Documentation](https://www.rubydoc.info/gems/httpi)

[![Development](https://github.com/savonrb/httpi/actions/workflows/development.yml/badge.svg)](https://github.com/savonrb/httpi/actions/workflows/development.yml)

## Installation

HTTPI is available through [Rubygems](https://rubygems.org/gems/httpi) and can be installed via:

$ gem install httpi

or add it to your Gemfile like this:

gem 'httpi', '~> 4.0.0'

## Usage example

``` ruby
require "httpi"

# create a request object
request = HTTPI::Request.new
request.url = "http://example.com"

# and pass it to a request method
HTTPI.get(request)

# use a specific adapter per request
HTTPI.get(request, :curb)

# or specify a global adapter to use
HTTPI.adapter = :httpclient

# and execute arbitary requests
HTTPI.request(:custom, request)

# add a client setup block that will be called before each request
HTTPI.adapter = :httpclient
HTTPI.adapter_client_setup = proc do |x|
x.ssl_config.set_default_paths
x.force_basic_auth = true
end
# ...
HTTPI.get(request) do |x|
x.force_basic_auth = false
end
```

### SOCKS Proxy Support

To use the the SOCKS proxy support, please add the `socksify` gem to your gemfile, and add the following code:

``` ruby
require 'socksify'
require 'socksify/http'
```

to your project.

## Documentation

Continue reading at https://www.rubydoc.info/gems/httpi