Skip to content
This repository has been archived by the owner on Dec 3, 2017. It is now read-only.
/ net-http-local Public archive

[mort] Binds a Net::HTTP request to a specified local address and port

License

Notifications You must be signed in to change notification settings

hakanensari/net-http-local

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Net::HTTP::Local

Net::HTTP::Local binds a Net::HTTP request to a specified local address and port.

Installation

gem install net-http-local

Usage

A contrived example:

require 'json'
require 'net/http/local'
require 'uri'


ip = -> do
  uri = URI.parse 'http://jsonip.com'
  res = Net::HTTP.get_response uri

  JSON.parse(res.body)['ip']
end
 
# The default IP address.
p ip.call # => 10.1.1.2

# Bind to 10.1.1.3 in a block.
Net::HTTP.bind '10.1.1.3' do
  p ip.call # => 10.1.1.3
end

# Bind and unbind without a block.
Net::HTTP.bind '10.1.1.3'
p ip.call # => 10.1.1.3
Net::HTTP.unbind

About

[mort] Binds a Net::HTTP request to a specified local address and port

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages