Project

tub

0.0
No commit activity in last 3 years
No release in over 3 years
The HTTP spec details a way to use HTTP/1.1 as a platform for transitioning to newer protocols by starting the conversation with HTTP/1.1. There are no restrictions on what that protocol can be.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Try It

Make a server

require 'tub'

class Echo < EM::Connection
  def receive_data(data)
    send_data(data)
  end
end

app = lambda{|env| [200, {'Content-Type' => 'text/plain'}, ["Hello world!"]]}

Thin::Server.start('0.0.0.0', 1345, app, :backend => TUB::UpgradableTcpServer, :handler_on_upgrade => Echo)

Connect to the server

telnet localhost 1345

Speak HTTP

GET / HTTP/1.1
Host: example.com

Now switch protocols

GET / HTTP/1.1
Host: example.com
Upgrade: Echo/1.0
Connection: Upgrade

And then type anything you want, it'll echo back to you

Hello world
Hello world

Have fun!

TODO

  • Make it actually care about what protocol the client requests and which you offer
  • Figure out rackup file
  • Show a sample app working in Heroku, with a sample client
  • Remove the Rack wrapper app and make it part of the example, but customizable, so you control when upgrade occurs