code: @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
      private static Request parse(final InputStream input) throws IOException {
          boolean eof = true;
          final Collection<String> head = new LinkedList<>();
          final ByteArrayOutputStream baos = new ByteArrayOutputStream();
          Opt<Integer> data = new Opt.Empty<>();
          data = RqLive.data(input, data, false);
          while (data.get() > 0) {
              eof = false;
              if (data.get() == '\r') {
                  RqLive.checkLineFeed(input, baos, head.size() + 1);
                  if (baos.size() == 0) {
                      break;
                  }
                  data = new Opt.Single<>(input.read());
                  final Opt<String> header = RqLive.newHeader(data, baos);
                  if (header.has()) {
                      head.add(header.get());
                  }
                  data = RqLive.data(input, data, false);
                  continue;
              }
              baos.write(RqLive.legalCharacter(data, baos, head.size() + 1));
              data = RqLive.data(input, new Opt.Empty<>(), true);
          }
          if (eof) {
              throw new IOException("empty request");
          }
          return new Request() {
              @Override
              public Iterable<String> head() {
                  return head;
              }
  
              @Override
              public InputStream body() {
                  return input;
              }
          };
      }
docs: Parse input stream.
  @param input Input stream
  @return Request
  @throws IOException If fails
  @checkstyle ExecutableStatementCountCheck (100 lines)