Method: HTTP::Protocol::HTTP2::Connection#receive_headers

Defined in:
lib/http/protocol/http2/connection.rb

#receive_headers(frame) ⇒ Object



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/http/protocol/http2/connection.rb', line 262

def receive_headers(frame)
  if frame.stream_id == 0
    raise ProtocolError, "Cannot receive headers for stream 0!"
  end
  
  if stream = @streams[frame.stream_id]
    stream.receive_headers(frame)
    
    if stream.closed?
      @streams.delete(stream.id)
    end
  elsif frame.stream_id > @remote_stream_id
    if @streams.count < self.maximum_concurrent_streams
      stream = create_stream(frame.stream_id)
      stream.receive_headers(frame)
      
      @remote_stream_id = stream.id
      @streams[stream.id] = stream
    else
      raise ProtocolError, "Exceeded maximum concurrent streams"
    end
  end
end