Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Reverse HTTP ruby client
Ruby
branch: master

This branch is 5 commits behind elcuervo:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/net
test
Gemfile
Gemfile.lock
HUGS
LICENSE
README.md
Rakefile
SPEC.md
net-ptth.gemspec

README.md

Net::PTTH

Net::HTTP compatible PTTH client

You misspelled HTTP

No I didn't: http://wiki.secondlife.com/wiki/Reverse_HTTP

Installation

gem install net-ptth

Usage

require 'net/ptth'
require 'net/http'

ptth = Net::PTTH.new("http://localhost:23045")
request = Net::HTTP::Post.new("/reverse")
ptth.request(request) do |incomming_request|
  # Handle the body of the incomming request through the reverse connection
  # This will be executed with each new request.
  # incomming_request it's a Rack::Request object
  # You can close the connection with:
  # ptth.close
end

Rack compatiblity

Remember that letting an app handle the responses it's also in charge of closing the reverse connection if needed

An app can be defined to be mounted like rackup will. So you can do things like this:

require 'net/ptth'
require 'net/http'

ptth = Net::PTTH.new("http://localhost:23045")
ptth.app = Cuba.define do
  on "dog" do
    res.write "Hello? this is dog"
  end
end

request = Net::HTTP::Post.new("/reverse")
ptth.request(request)

And let the app handle the responses of the reverse connection. Both Cuba and sinatra were tested

Something went wrong with that request. Please try again.