Class: Protocol::HTTP2::ResetStreamFrame

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

Overview

The RST_STREAM frame allows for immediate termination of a stream. RST_STREAM is sent to request cancellation of a stream or to indicate that an error condition has occurred.

--------------------------------------------------------------- | Error Code (32) | ---------------------------------------------------------------

Constant Summary collapse

TYPE =
0x3
FORMAT =
"N".freeze

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, #connection?, #flag_set?, #header, #initialize, #inspect, parse_header, #read, #read_header, #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



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

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

#pack(error_code = NO_ERROR) ⇒ Object



39
40
41
42
# File 'lib/protocol/http2/reset_stream_frame.rb', line 39

def pack(error_code = NO_ERROR)
	@payload = [error_code].pack(FORMAT)
	@length = @payload.bytesize
end

#read_payload(stream) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/protocol/http2/reset_stream_frame.rb', line 48

def read_payload(stream)
	super
	
	if @length != 4
		raise FrameSizeError, "Invalid frame length"
	end
end

#unpackObject



35
36
37
# File 'lib/protocol/http2/reset_stream_frame.rb', line 35

def unpack
	@payload.unpack1(FORMAT)
end