Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for PING packets #9

Merged
merged 2 commits into from

2 participants

@jonasschneider
Collaborator

No description provided.

@igrigorik igrigorik merged commit c26f42a into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 29, 2011
  1. @jonasschneider

    also parse PING frames

    jonasschneider authored
Commits on Dec 30, 2011
  1. @jonasschneider
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 0 deletions.
  1. +10 −0 lib/spdy/parser.rb
  2. +8 −0 spec/parser_spec.rb
View
10 lib/spdy/parser.rb
@@ -18,6 +18,10 @@ def on_headers_complete(&blk)
@on_headers_complete = blk
end
+ def on_ping(&blk)
+ @on_ping = blk
+ end
+
def on_body(&blk)
@on_body = blk
end
@@ -66,6 +70,12 @@ def try_parse
unpack_control(pckt, @buffer)
@on_message_complete.call(pckt.header.stream_id) if @on_message_complete && fin?(pckt.header)
+
+ when 6 then # PING
+ pckt = Control::Ping.new({:zlib_session => @zlib_session})
+ pckt.read(@buffer)
+
+ @on_ping.call(pckt.ping_id) if @on_ping
else
raise 'invalid control frame'
View
8 spec/parser_spec.rb
@@ -68,6 +68,14 @@
headers.class.should == Hash
headers['version'].should == "HTTP/1.1"
end
+
+ it "should parse PING packet" do
+ fired = false
+ s.on_ping { |num| fired = num }
+ s << PING
+
+ fired.should == 1
+ end
end
context "DATA" do
Something went wrong with that request. Please try again.