Sha256: a150e8278e69c3f6bc9849aee7dc8f8bdfdd474124af361925568044ae75e3a5

Contents?: true

Size: 1.31 KB

Versions: 6

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2019-2024, 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

6 entries across 6 versions & 1 rubygems

Version Path
protocol-http2-0.20.0 lib/protocol/http2/data_frame.rb
protocol-http2-0.19.4 lib/protocol/http2/data_frame.rb
protocol-http2-0.19.3 lib/protocol/http2/data_frame.rb
protocol-http2-0.19.2 lib/protocol/http2/data_frame.rb
protocol-http2-0.19.1 lib/protocol/http2/data_frame.rb
protocol-http2-0.19.0 lib/protocol/http2/data_frame.rb