MCPcopy Index your code
hub / github.com/apache/tomcat / readHeadersFrame

Method readHeadersFrame

java/org/apache/coyote/http2/Http2Parser.java:236–305  ·  view source on GitHub ↗
(int streamId, int flags, int payloadSize, ByteBuffer buffer)

Source from the content-addressed store, hash-verified

234
235
236 protected void readHeadersFrame(int streamId, int flags, int payloadSize, ByteBuffer buffer)
237 throws Http2Exception, IOException {
238
239 headersEndStream = Flags.isEndOfStream(flags);
240
241 try {
242 hpackDecoder.setHeaderEmitter(output.headersStart(streamId, headersEndStream));
243 } catch (StreamException se) {
244 swallowPayload(streamId, FrameType.HEADERS.getId(), payloadSize, false, buffer);
245 throw se;
246 }
247
248 int padLength = 0;
249 boolean padding = Flags.hasPadding(flags);
250 boolean priority = Flags.hasPriority(flags);
251 int optionalLen = 0;
252 if (padding) {
253 optionalLen = 1;
254 }
255 if (priority) {
256 optionalLen += 5;
257 }
258
259 // Frame is too small to contain mandatory frame data (for the given flags)
260 if (payloadSize < optionalLen) {
261 throw new ConnectionException(sm.getString("http2Parser.processFrame.insufficientPayload",connectionId,
262 Integer.toString(streamId), Integer.toString(FrameType.HEADERS.getId()),
263 Integer.toString(flags), Integer.toString(payloadSize)), Http2Error.FRAME_SIZE_ERROR);
264 }
265
266 if (optionalLen > 0) {
267 byte[] optional = new byte[optionalLen];
268 if (buffer == null) {
269 input.fill(true, optional);
270 } else {
271 buffer.get(optional);
272 }
273 /*
274 * The optional padLength byte and priority bytes (if any) don't count towards the payload size when
275 * comparing payload size to padLength as required by RFC 9113, section 6.2.
276 */
277 payloadSize -= optionalLen;
278
279 if (padding) {
280 padLength = ByteUtil.getOneByte(optional, 0);
281 if (padLength >= payloadSize) {
282 throw new ConnectionException(sm.getString("http2Parser.processFrame.tooMuchPadding", connectionId,
283 Integer.toString(streamId), Integer.toString(padLength), Integer.toString(payloadSize)),
284 Http2Error.PROTOCOL_ERROR);
285 }
286 }
287 // The padding does not count towards the size of payload that is read below.
288 payloadSize -= padLength;
289
290 // Any RFC 7450 priority data was read into the byte[] optional above. It is ignored.
291 }
292
293 readHeaderPayload(streamId, payloadSize, buffer);

Callers 2

readFrameMethod · 0.95
completedMethod · 0.80

Calls 15

isEndOfStreamMethod · 0.95
swallowPayloadMethod · 0.95
hasPaddingMethod · 0.95
hasPriorityMethod · 0.95
getOneByteMethod · 0.95
readHeaderPayloadMethod · 0.95
isEndOfHeadersMethod · 0.95
onHeadersCompleteMethod · 0.95
setHeaderEmitterMethod · 0.80
getHeaderEmitterMethod · 0.80
headersStartMethod · 0.65
getIdMethod · 0.65

Tested by

no test coverage detected