Project

net-ptth

0.01
No commit activity in last 3 years
No release in over 3 years
PTTH Ruby client. Net::HTTP compatible... kind of
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 3.1.0
~> 4.4.0
~> 1.3.3

Runtime

>= 0.15.0
>= 0.6.0.beta.2
>= 1.4.5
 Project Readme

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