Method: Protocol::HTTP2::Padded#pack

Defined in:
lib/protocol/http2/padded.rb

#pack(data, padding_size: nil, maximum_size: nil) ⇒ Object

Pack data with optional padding into the frame.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/protocol/http2/padded.rb', line 34

def pack(data, padding_size: nil, maximum_size: nil)
	if padding_size
		set_flags(PADDED)
		
		buffer = String.new.b
		
		buffer << padding_size
		buffer << data
		
		if padding_size
			buffer << ("\0" * padding_size)
		end
		
		super buffer
	else
		clear_flags(PADDED)
		
		super data
	end
end