@Override
  public void close() throws IOException {
    if (log.isDebugEnabled()) log.debug("close(targetId=" + targetId);

    boolean alreadyClosed = closed.getAndSet(true);
    if (log.isDebugEnabled()) log.debug("alreadyClosed=" + alreadyClosed);
    if (!alreadyClosed) {

      if (log.isDebugEnabled())
        log.debug(
            "complete AsyncContext of targetId="
                + targetId
                + " with status="
                + HttpServletResponse.SC_OK);

      // The stream data must be completely read.
      // Otherwise the data remains in the socket and
      // disturbs the next request.
      while (is.read() != -1) {
        // if (log.isDebugEnabled()) log.debug("read before close, " + (char)c);
      }
      is.close();

      HttpServletResponse response = (HttpServletResponse) rctxt.getResponse();
      response.getOutputStream().close();
      response.setStatus(HttpServletResponse.SC_OK);
      rctxt.complete();

      super.close();
    }
    if (log.isDebugEnabled()) log.debug(")close");
  }
 HIncomingStreamAsync(
     BTargetId targetId,
     String contentType,
     long contentLength,
     String contentDisposition,
     long lifetimeMillis,
     File tempDir,
     HRequestContext rctxt)
     throws IOException {
   super(contentType, contentLength, lifetimeMillis);
   this.setTargetId(targetId);
   this.rctxt = rctxt;
   this.is = rctxt.getRequest().getInputStream();
   this.tempDir = tempDir;
   setContentDisposition(contentDisposition);
 }