Class: HTTP2::FrameBuffer
- Inherits:
-
Object
- Object
- HTTP2::FrameBuffer
show all
- Includes:
- BufferUtils
- Defined in:
- lib/http/2/flow_buffer.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#append_str, #read_str, #read_uint32
Constructor Details
Returns a new instance of FrameBuffer.
122
123
124
125
|
# File 'lib/http/2/flow_buffer.rb', line 122
def initialize
@buffer = []
@bytesize = 0
end
|
Instance Attribute Details
#bytesize ⇒ Object
Returns the value of attribute bytesize.
120
121
122
|
# File 'lib/http/2/flow_buffer.rb', line 120
def bytesize
@bytesize
end
|
Instance Method Details
#<<(frame) ⇒ Object
127
128
129
130
|
# File 'lib/http/2/flow_buffer.rb', line 127
def <<(frame)
@buffer << frame
@bytesize += frame[:payload].bytesize
end
|
#clear ⇒ Object
132
133
134
135
|
# File 'lib/http/2/flow_buffer.rb', line 132
def clear
@buffer.clear
@bytesize = 0
end
|
#empty? ⇒ Boolean
137
138
139
|
# File 'lib/http/2/flow_buffer.rb', line 137
def empty?
@buffer.empty?
end
|
#retrieve(window_size) ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/http/2/flow_buffer.rb', line 141
def retrieve(window_size)
frame = @buffer.first or return
frame_size = frame[:payload].bytesize
end_stream = frame[:flags].anybits?(END_STREAM)
return if window_size <= 0 && !(frame_size.zero? && end_stream)
if frame_size > window_size
chunk = frame.dup
chunk[:payload] = read_str(frame[:payload], window_size) chunk[:length] = window_size
frame[:length] = frame_size - window_size
chunk[:flags] ^= END_STREAM if end_stream
@bytesize -= window_size
chunk
else
@bytesize -= frame_size
@buffer.shift
end
end
|