Skip to content

Commit

Permalink
fix handling of headerless SYN_STREAM frames
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschneider committed Jan 4, 2012
1 parent c86e084 commit e5e25e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/spdy/protocol.rb
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions spec/protocol_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit e5e25e0

Please sign in to comment.