Sha256: 77c084d31d1264d198f2f8ae08d21f454fd1220d5346ffcf42764d4a50aef89a

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.

require_relative 'frame'
require_relative 'padded'

module Protocol
	module HTTP2
		# DATA frames convey arbitrary, variable-length sequences of octets associated with a stream. One or more DATA frames are used, for instance, to carry HTTP request or response payloads.
		# 
		# DATA frames MAY also contain padding. Padding can be added to DATA frames to obscure the size of messages.
		# 
		# +---------------+
		# |Pad Length? (8)|
		# +---------------+-----------------------------------------------+
		# |                            Data (*)                         ...
		# +---------------------------------------------------------------+
		# |                           Padding (*)                       ...
		# +---------------------------------------------------------------+
		#
		class DataFrame < Frame
			include Padded
			
			TYPE = 0x0
			
			def end_stream?
				flag_set?(END_STREAM)
			end
			
			def pack(data, *arguments, **options)
				if data
					super
				else
					@length = 0
					set_flags(END_STREAM)
				end
			end
			
			def apply(connection)
				connection.receive_data(self)
			end
			
			def inspect
				"\#<#{self.class} stream_id=#{@stream_id} flags=#{@flags} #{@length || 0}b>"
			end
		end
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
protocol-http2-0.18.0 lib/protocol/http2/data_frame.rb
protocol-http2-0.17.0 lib/protocol/http2/data_frame.rb
protocol-http2-0.16.0 lib/protocol/http2/data_frame.rb
protocol-http2-0.15.1 lib/protocol/http2/data_frame.rb
protocol-http2-0.15.0 lib/protocol/http2/data_frame.rb