code: private String readAsciiUntilCrlf(InputStream in) throws IOException {
          StringBuilder builder = new StringBuilder();
          while (true) {
              int c = in.read();
              if (c == '\n' && builder.length() > 0 && builder.charAt(builder.length() - 1) == '\r') {
                  builder.deleteCharAt(builder.length() - 1);
                  return builder.toString();
              } else if (c == -1) {
                  return builder.toString();
              } else {
                  builder.append((char) c);
              }
          }
      }
docs: Returns the text from {@code in} until the next "\r\n", or null if
  {@code in} is exhausted.