void maybePadHeader()

in proprot/src/com/amazonaws/proprot/Generator.java [179:202]


    void maybePadHeader(int knownSize, OutputStream out) throws IOException {
        if (!enforcedSize.isPresent()) {
            return;
        }
        int targetSize = enforcedSize.get();
        if (knownSize == targetSize) {
            // nothing to do
            return;
        }
        if (knownSize > targetSize) {
            throw new InvalidHeaderException("Header size " + knownSize
                    + " can not be larger than the specified limit " + targetSize);
        }

        int remainingSize = targetSize - knownSize;
        if (remainingSize == 1 || remainingSize == 2) {
            throw new InvalidHeaderException("Due to Proxy Protocol limitation can not pad header "
                    + "of size " + knownSize + " by 1 or 2 bytes to the specified limit "
                    + targetSize);
        } else {
            int padSize = remainingSize - getTlvStartSize();
            padHeader(padSize, out);
        }
    }