Module: Protocol::HTTP2::Continued

Included in:
ContinuationFrame, HeadersFrame, PushPromiseFrame
Defined in:
lib/protocol/http2/continuation_frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#continuationObject

Returns the value of attribute continuation.



54
55
56
# File 'lib/protocol/http2/continuation_frame.rb', line 54

def continuation
  @continuation
end

Instance Method Details

#end_headers?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/protocol/http2/continuation_frame.rb', line 32

def end_headers?
	flag_set?(END_HEADERS)
end

#initializeObject



26
27
28
29
30
# File 'lib/protocol/http2/continuation_frame.rb', line 26

def initialize(*)
	super
	
	@continuation = nil
end

#pack(data, **options) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/protocol/http2/continuation_frame.rb', line 56

def pack(data, **options)
	maximum_size = options[:maximum_size]
	
	if maximum_size and data.bytesize > maximum_size
		clear_flags(END_HEADERS)
		
		super(data.byteslice(0, maximum_size), **options)
		
		remainder = data.byteslice(maximum_size, data.bytesize-maximum_size)
		
		@continuation = ContinuationFrame.new
		@continuation.pack(remainder, maximum_size: maximum_size)
	else
		set_flags(END_HEADERS)
		
		super data, **options
		
		@continuation = nil
	end
end

#read(stream, maximum_frame_size) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/protocol/http2/continuation_frame.rb', line 36

def read(stream, maximum_frame_size)
	super
	
	unless end_headers?
		@continuation = ContinuationFrame.new
		
		@continuation.read(stream, maximum_frame_size)
	end
end

#unpackObject



77
78
79
80
81
82
83
# File 'lib/protocol/http2/continuation_frame.rb', line 77

def unpack
	if @continuation.nil?
		super
	else
		super + @continuation.unpack
	end
end

#write(stream) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/protocol/http2/continuation_frame.rb', line 46

def write(stream)
	super
	
	if continuation = self.continuation
		continuation.write(stream)
	end
end