Permalink
Browse files

fix handling of headerless SYN_STREAM frames

  • Loading branch information...
1 parent c86e084 commit e5e25e0cb983609686f52f8c331dc5ca311688c3 @jonasschneider jonasschneider committed Jan 4, 2012
Showing with 23 additions and 3 deletions.
  1. +8 −3 lib/spdy/protocol.rb
  2. +15 −0 spec/protocol_spec.rb
View
@@ -21,9 +21,14 @@ def initialize_instance
def parse(chunk)
head = Control::Header.new.read(chunk)
self.read(chunk)
-
- data = @zlib_session.inflate(self.data.to_s)
- self.uncompressed_data = NV.new.read(data)
+
+ if data.length > 0
+ data = @zlib_session.inflate(self.data.to_s)
+ self.uncompressed_data = NV.new.read(data)
+ else
+ self.uncompressed_data = NV.new
+ end
+
self
end
View
@@ -72,6 +72,21 @@
sr.to_binary_s.should == SYN_STREAM
end
+
+ it "should parse a SYN_STREAM without headers" do
+ zlib_session = SPDY::Zlib.new
+
+ src = SPDY::Protocol::Control::SynStream.new
+ src.header.stream_id = 3
+ src.header.type = 1
+ src.header.flags = 0x01
+ src.header.len = 10
+
+ packet = SPDY::Protocol::Control::SynStream.new({:zlib_session => zlib_session})
+ packet.parse(src.to_binary_s)
+
+ packet.uncompressed_data.to_h.should == {}
+ end
end
describe "SYN_REPLY" do

0 comments on commit e5e25e0

Please sign in to comment.