Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elcuervo/net-ptth
Reverse HTTP ruby client
https://github.com/elcuervo/net-ptth
Last synced: 3 months ago
JSON representation
Reverse HTTP ruby client
- Host: GitHub
- URL: https://github.com/elcuervo/net-ptth
- Owner: elcuervo
- License: mit
- Created: 2013-01-14T15:30:56.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2022-11-19T18:38:12.000Z (about 2 years ago)
- Last Synced: 2024-04-24T04:29:26.212Z (9 months ago)
- Language: Ruby
- Size: 43 KB
- Stars: 7
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Net::PTTH
`Net::HTTP` compatible `PTTH` client
## You misspelled HTTP
No I didn't: http://wiki.secondlife.com/wiki/Reverse_HTTP
## Installation
```bash
gem install net-ptth
```## Usage
```ruby
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:```ruby
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
endrequest = 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