try {
            while (true) {
                final int bytes = input.read(buf);
                if (bytes < 0) {
                    break;