Module: Protocol::HTTP2::Continued
- Included in:
- ContinuationFrame, HeadersFrame, PushPromiseFrame
- Defined in:
- lib/protocol/http2/continuation_frame.rb
Instance Attribute Summary collapse
-
#continuation ⇒ Object
Returns the value of attribute continuation.
Instance Method Summary collapse
- #continued? ⇒ Boolean
- #end_headers? ⇒ Boolean
- #initialize ⇒ Object
- #pack(data, **options) ⇒ Object
- #read(stream, maximum_frame_size) ⇒ Object
- #unpack ⇒ Object
- #write(stream) ⇒ Object
Instance Attribute Details
#continuation ⇒ Object
Returns the value of attribute continuation.
55 56 57 |
# File 'lib/protocol/http2/continuation_frame.rb', line 55 def continuation @continuation end |
Instance Method Details
#continued? ⇒ Boolean
17 18 19 |
# File 'lib/protocol/http2/continuation_frame.rb', line 17 def continued? !!@continuation end |
#end_headers? ⇒ Boolean
21 22 23 |
# File 'lib/protocol/http2/continuation_frame.rb', line 21 def end_headers? flag_set?(END_HEADERS) end |
#initialize ⇒ Object
11 12 13 14 15 |
# File 'lib/protocol/http2/continuation_frame.rb', line 11 def initialize(*) super @continuation = nil end |
#pack(data, **options) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/protocol/http2/continuation_frame.rb', line 57 def pack(data, **) maximum_size = [:maximum_size] if maximum_size and data.bytesize > maximum_size clear_flags(END_HEADERS) super(data.byteslice(0, maximum_size), **) 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, ** @continuation = nil end end |
#read(stream, maximum_frame_size) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/protocol/http2/continuation_frame.rb', line 25 def read(stream, maximum_frame_size) super unless end_headers? continuation = ContinuationFrame.new continuation.read_header(stream) # We validate the frame type here: unless continuation.valid_type? raise ProtocolError, "Invalid frame type: #{@type}!" end if continuation.stream_id != @stream_id raise ProtocolError, "Invalid stream id: #{continuation.stream_id} for continuation of stream id: #{@stream_id}!" end continuation.read(stream, maximum_frame_size) @continuation = continuation end end |
#unpack ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/protocol/http2/continuation_frame.rb', line 78 def unpack if @continuation.nil? super else super + @continuation.unpack end end |
#write(stream) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/protocol/http2/continuation_frame.rb', line 47 def write(stream) super if continuation = self.continuation continuation.write(stream) end end |