code: public static void copy(HttpServletRequest req, OutputStream output) throws IOException {
          InputStream input = req.getInputStream();
          int availableBytes = req.getContentLength();
          log.debug("copy - available: {}", availableBytes);
          if (availableBytes > 0) {
              byte[] buf = new byte[availableBytes];
              int bytesRead = input.read(buf);
              while (bytesRead != -1) {
                  output.write(buf, 0, bytesRead);
                  bytesRead = input.read(buf);
                  log.trace("Bytes read: {}", bytesRead);
              }
              output.flush();
          } else {
              log.debug("Nothing to available to copy");
          }
      }
docs: Copies information from the http request to the output stream using the specified content length.
  
  @param req
  Request
  @param output
  Output stream
  @throws java.io.IOException
  on error