Class: HTTP::Protocol::HTTP2::ResetStreamFrame

Inherits:
Frame
  • Object
show all
Defined in:
lib/http/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, parse_header, #read, #read_header, #set_flags, #to_ary, #write, #write_header, #write_payload

Constructor Details

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

Instance Method Details

#apply(connection) ⇒ Object



60
61
62
# File 'lib/http/protocol/http2/reset_stream_frame.rb', line 60

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

#pack(error_code = NO_ERROR) ⇒ Object



55
56
57
58
# File 'lib/http/protocol/http2/reset_stream_frame.rb', line 55

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

#read_payload(stream) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/http/protocol/http2/reset_stream_frame.rb', line 64

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

#unpackObject



51
52
53
# File 'lib/http/protocol/http2/reset_stream_frame.rb', line 51

def unpack
	@payload.unpack(FORMAT).first
end