Method: Protocol::HTTP2::Framer#read_frame

Defined in:
lib/protocol/http2/framer.rb

#read_frame(maximum_frame_size = MAXIMUM_ALLOWED_FRAME_SIZE) ⇒ Frame

Returns the frame that has been read from the underlying IO.

Returns:

  • (Frame)

    the frame that has been read from the underlying IO.

Raises:

  • if the underlying IO fails for some reason.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/protocol/http2/framer.rb', line 91

def read_frame(maximum_frame_size = MAXIMUM_ALLOWED_FRAME_SIZE)
  # Read the header:
  length, type, flags, stream_id = read_header
  
  # Console.debug(self) {"read_frame: length=#{length} type=#{type} flags=#{flags} stream_id=#{stream_id} -> klass=#{@frames[type].inspect}"}
  
  # Allocate the frame:
  klass = @frames[type] || Frame
  frame = klass.new(stream_id, flags, type, length)
  
  # Read the payload:
  frame.read(@stream, maximum_frame_size)
  
  # Console.debug(self, name: "read") {frame.inspect}
  
  return frame
end