Class: Protocol::HTTP2::GoawayFrame

Inherits:
Frame
  • Object
show all
Defined in:
lib/protocol/http2/goaway_frame.rb

Overview

The GOAWAY frame is used to initiate shutdown of a connection or to signal serious error conditions. GOAWAY allows an endpoint to gracefully stop accepting new streams while still finishing processing of previously established streams. This enables administrative actions, like server maintenance.

-————————————————————-+ |R| Last-Stream-ID (31) | -————————————————————-+ | Error Code (32) | --------------------------------------------------------------- | Additional Debug Data (*) | ---------------------------------------------------------------

Constant Summary collapse

TYPE =
0x7
FORMAT =
"NN"

Constants inherited from Frame

Frame::HEADER_FORMAT, Frame::LENGTH_HISHIFT, Frame::LENGTH_LOMASK, Frame::STREAM_ID_MASK, Frame::VALID_LENGTH, Frame::VALID_STREAM_ID

Instance Attribute Summary

Attributes inherited from Frame

#flags, #length, #payload, #stream_id, #type

Instance Method Summary collapse

Methods inherited from Frame

#<=>, #clear_flags, #flag_set?, #header, #initialize, #inspect, parse_header, #read, #read_header, #read_payload, #set_flags, #to_ary, #valid_type?, #write, #write_header, #write_payload

Constructor Details

This class inherits a constructor from Protocol::HTTP2::Frame

Instance Method Details

#apply(connection) ⇒ Object

Apply this GOAWAY frame to a connection for processing.



50
51
52
# File 'lib/protocol/http2/goaway_frame.rb', line 50

def apply(connection)
  connection.receive_goaway(self)
end

#connection?Boolean

Check if this frame applies to the connection level.

Returns:

  • (Boolean)


26
27
28
# File 'lib/protocol/http2/goaway_frame.rb', line 26

def connection?
  true
end

#pack(last_stream_id, error_code, data) ⇒ Object

Pack GOAWAY frame data into payload.



44
45
46
# File 'lib/protocol/http2/goaway_frame.rb', line 44

def pack(last_stream_id, error_code, data)
  super [last_stream_id, error_code].pack(FORMAT) + data
end

#unpackObject

Unpack the GOAWAY frame payload.



32
33
34
35
36
37
38
# File 'lib/protocol/http2/goaway_frame.rb', line 32

def unpack
  data = super
  
  last_stream_id, error_code = data.unpack(FORMAT)
  
  return last_stream_id, error_code, data.slice(8, data.bytesize-8)
end