Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tag: v0.0.2
Fetching contributors…

Cannot retrieve contributors at this time

54 lines (41 sloc) 1.286 kB
$: << 'lib' << '../lib'
require 'eventmachine'
require 'spdy'
class SPDYHandler < EM::Connection
def post_init
@parser = SPDY::Parser.new
@parser.on_headers_complete do |stream_id, associated_stream, priority, headers|
p [:SPDY_HEADERS, headers]
sr = SPDY::Protocol::Control::SynReply.new
h = {'Content-Type' => 'text/plain', 'status' => '200 OK', 'version' => 'HTTP/1.1'}
sr.create(:stream_id => 1, :headers => h)
send_data sr.to_binary_s
p [:SPDY, :sent, :SYN_REPLY]
d = SPDY::Protocol::Data::Frame.new
d.create(:stream_id => 1, :data => "This is SPDY.")
send_data d.to_binary_s
p [:SPDY, :sent, :DATA]
d = SPDY::Protocol::Data::Frame.new
d.create(:stream_id => 1, :flags => 1)
send_data d.to_binary_s
p [:SPDY, :sent, :DATA_FIN]
end
start_tls
end
def receive_data(data)
@parser << data
end
def unbind
p [:SPDY, :connection_closed]
end
end
EM.run do
EM.start_server '0.0.0.0', 10000, SPDYHandler
end
# (1) start the SPDY eventmachine server
# > ruby spdy_server.rb
#
# (2) start Chrome and force it to use SPDY over SSL.. on OSX:
# > /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --use-spdy=ssl
#
# (3) visit https://localhost:1000/
Jump to Line
Something went wrong with that request. Please try again.