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

Method swallowPayload

java/org/apache/coyote/http2/Http2Parser.java:613–661  ·  view source on GitHub ↗

Swallow some or all of the bytes from the payload of an HTTP/2 frame. @param streamId Stream being swallowed @param frameTypeId Type of HTTP/2 frame for which the bytes will be swallowed @param len Number of bytes to swallow @param isPadding Are the bytes to be swallowed padding bytes?

(int streamId, int frameTypeId, int len, boolean isPadding, ByteBuffer byteBuffer)

Source from the content-addressed store, hash-verified

611 * @throws ConnectionException If the swallowed bytes are expected to have a value of zero but do not
612 */
613 protected void swallowPayload(int streamId, int frameTypeId, int len, boolean isPadding, ByteBuffer byteBuffer)
614 throws IOException, ConnectionException {
615 if (log.isTraceEnabled()) {
616 log.trace(sm.getString("http2Parser.swallow.debug", connectionId, Integer.toString(streamId),
617 Integer.toString(len)));
618 }
619 try {
620 if (len == 0) {
621 return;
622 }
623 if (!isPadding && byteBuffer != null) {
624 byteBuffer.position(byteBuffer.position() + len);
625 } else {
626 int read = 0;
627 byte[] buffer = new byte[1024];
628 while (read < len) {
629 int thisTime = Math.min(buffer.length, len - read);
630 if (byteBuffer == null) {
631 input.fill(true, buffer, 0, thisTime);
632 } else {
633 byteBuffer.get(buffer, 0, thisTime);
634 }
635 if (isPadding) {
636 // Validate the padding is zero since receiving non-zero padding
637 // is a strong indication of either a faulty client or a server
638 // side bug.
639 for (int i = 0; i < thisTime; i++) {
640 if (buffer[i] != 0) {
641 throw new ConnectionException(sm.getString("http2Parser.nonZeroPadding", connectionId,
642 Integer.toString(streamId)), Http2Error.PROTOCOL_ERROR);
643 }
644 }
645 }
646 read += thisTime;
647 }
648 }
649 } finally {
650 if (FrameType.DATA.getIdByte() == frameTypeId) {
651 if (isPadding) {
652 // Need to add 1 for the padding length bytes that was also
653 // part of the payload.
654 len += 1;
655 }
656 if (len > 0) {
657 output.onSwallowedDataFramePayload(streamId, len);
658 }
659 }
660 }
661 }
662
663
664 protected void onHeadersComplete(int streamId) throws Http2Exception {

Callers 7

readFrameMethod · 0.95
readDataFrameMethod · 0.95
readHeadersFrameMethod · 0.95
readPriorityFrameMethod · 0.95
readUnknownFrameMethod · 0.95
completedMethod · 0.80
completedMethod · 0.80

Calls 10

positionMethod · 0.80
getIdByteMethod · 0.80
isTraceEnabledMethod · 0.65
traceMethod · 0.65
getStringMethod · 0.65
toStringMethod · 0.65
fillMethod · 0.65
getMethod · 0.65
minMethod · 0.45

Tested by

no test coverage detected