int gets(byte[] buffer) throws IOException {
        if (buffer == null || buffer.length == 0) {
            return 0;
        }

        int offset = 0;
        int inputByte = 0;
        while (offset < buffer.length) {
            inputByte = read();
            if (inputByte == -1) {
                // EOF
                break;
            }
            if (inputByte == '\n') {
                if (offset == 0) {
                    // If we haven't read anything yet, ignore CRLF.
                    continue;
                } else {
                    break;
                }
            }

            buffer[offset++] = (byte) inputByte;
        }

        return offset;
    }
Similar to a {@code readLine} method, but matches what OpenSSL expects
from a {@code BIO_gets} method.
common/src/main/java/org/conscrypt/OpenSSLBIOInputStream.java