Permalink
Browse files

Merge pull request #6 from jonasschneider/multi-frame

When parsing of a frame succeeds, try parsing another one
  • Loading branch information...
igrigorik committed Jan 1, 2012
2 parents c26f42a + 6aa0c17 commit 6e75aa7d15b66edb3e7b3b39abe7d3c2a5445982
Showing with 11 additions and 0 deletions.
  1. +4 −0 lib/spdy/parser.rb
  2. +7 −0 spec/parser_spec.rb
View
@@ -50,6 +50,7 @@ def unpack_control(pckt, data)
end
def try_parse
+ return if @buffer.empty?
type = @buffer[0,1].unpack('C').first >> 7 & 0x01
pckt = nil
@@ -94,6 +95,9 @@ def try_parse
# remove parsed data from the buffer
@buffer.slice!(0...pckt.num_bytes)
+
+ # try parsing another frame
+ try_parse
rescue IOError => e
# rescue partial parse and wait for more data
View
@@ -44,6 +44,13 @@
fired.should be_true
end
+ it "should parse multiple frames in a single buffer" do
+ fired = 0
+ s.on_body { |stream_id, d| fired += 1 }
+ s << DATA*2
+ fired.should == 2
+ end
+
context "CONTROL" do
it "should parse SYN_STREAM packet" do
fired = false

0 comments on commit 6e75aa7

Please sign in to comment.