private void verifyHeadersFrame() throws Http2Exception {
    verifyNotProcessingHeaders();
    verifyPayloadLength(payloadLength);

    int lengthWithoutPriority = flags.getNumPaddingLengthBytes();
    if (lengthWithoutPriority < 0) {
      throw protocolError("Frame length too small." + payloadLength);
    }

    if (!flags.isPaddingLengthValid()) {
      throw protocolError("Pad high is set but pad low is not");
    }

    if (lengthWithoutPriority < flags.getNumPaddingLengthBytes()) {
      throw protocolError("Frame length %d too small for padding.", payloadLength);
    }
  }
  private void verifyDataFrame() throws Http2Exception {
    verifyNotProcessingHeaders();
    verifyPayloadLength(payloadLength);

    if (!flags.isPaddingLengthValid()) {
      throw protocolError("Pad high is set but pad low is not");
    }
    if (payloadLength < flags.getNumPaddingLengthBytes()) {
      throw protocolError("Frame length %d too small.", payloadLength);
    }
  }
  private void verifyPushPromiseFrame() throws Http2Exception {
    verifyNotProcessingHeaders();
    verifyPayloadLength(payloadLength);

    if (!flags.isPaddingLengthValid()) {
      throw protocolError("Pad high is set but pad low is not");
    }

    // Subtract the length of the promised stream ID field, to determine the length of the
    // rest of the payload (header block fragment + payload).
    int lengthWithoutPromisedId = payloadLength - INT_FIELD_LENGTH;
    if (lengthWithoutPromisedId < flags.getNumPaddingLengthBytes()) {
      throw protocolError("Frame length %d too small for padding.", payloadLength);
    }
  }
  private void verifyContinuationFrame() throws Http2Exception {
    verifyPayloadLength(payloadLength);

    if (headersContinuation == null) {
      throw protocolError("Received %s frame but not currently processing headers.", frameType);
    }

    if (streamId != headersContinuation.getStreamId()) {
      throw protocolError(
          "Continuation stream ID does not match pending headers. "
              + "Expected %d, but received %d.",
          headersContinuation.getStreamId(), streamId);
    }

    if (!flags.isPaddingLengthValid()) {
      throw protocolError("Pad high is set but pad low is not");
    }

    if (payloadLength < flags.getNumPaddingLengthBytes()) {
      throw protocolError("Frame length %d too small for padding.", payloadLength);
    }
  }