private void wire(final String header, final byte[] b, final int pos, final int off) {
        final StringBuilder buffer = getStringBuilder();
        for (int i = 0; i < off; i++) {
            final int ch = b[pos + i];
            if (ch == 13) {
                buffer.append("[\\r]");
            } else if (ch == 10) {
                buffer.append("[\\n]\"");
                buffer.insert(0, "\"");
                buffer.insert(0, header);
                log.debug("{} {}", this.id, buffer);
                buffer.setLength(0);
            } else if (ch < 32 || ch >= 127) {
                buffer.append("[0x");
                buffer.append(Integer.toHexString(ch));
                buffer.append("]");
            } else {
                buffer.append((char) ch);
            }
        }
        if (buffer.length() > 0) {
            buffer.append('\"');
            buffer.insert(0, '\"');
            buffer.insert(0, header);
            log.debug("{} {}", this.id, buffer);
        }
    }
Ensures that the char[] array of the specified StringBuilder does not exceed the specified number of characters.
This method is useful to ensure that excessively long char[] arrays are not kept in memory forever.

@param stringBuilder the StringBuilder to check
@param maxSize the maximum number of characters the StringBuilder is allowed to have
httpclient5/src/main/java/org/apache/hc/client5/http/impl/Wire.java