Module: SPDY::Protocol::Control::Helpers

Included in:
Headers, SynReply, SynStream
Defined in:
lib/spdy/protocol.rb

Instance Method Summary collapse

Instance Method Details

#build(opts = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/spdy/protocol.rb', line 30

def build(opts = {})
  self.header.type  = opts[:type]
  self.header.len   = opts[:len]

  self.header.flags   = opts[:flags] || 0
  self.header.stream_id = opts[:stream_id]

  nv = SPDY::Protocol::NV.new
  nv.create(opts[:headers])

  nv = @zlib_session.deflate(nv.to_binary_s)
  self.header.len = self.header.len.to_i + nv.size

  self.data = nv

  self
end

#initialize_instanceObject



16
17
18
19
# File 'lib/spdy/protocol.rb', line 16

def initialize_instance
  super
  @zlib_session = @params[:zlib_session]
end

#parse(chunk) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/spdy/protocol.rb', line 21

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)
  self
end