public void close() {
    if (closed) {
      return;
    }
    closed = true;

    /* close the underlying connection if,
     * a) the streams not set up yet, no response can be sent, or
     * b) if the wrapper output stream is not set up, or
     * c) if the close of the input/outpu stream fails
     */
    try {
      if (uis_orig == null || uos == null) {
        connection.close();
        return;
      }
      if (!uos_orig.isWrapped()) {
        connection.close();
        return;
      }
      if (!uis_orig.isClosed()) {
        uis_orig.close();
      }
      uos.close();
    } catch (IOException e) {
      connection.close();
    }
  }
 public void close() throws IOException {
   if (closed) {
     return;
   }
   closed = true;
   flush();
   LeftOverInputStream is = t.getOriginalInputStream();
   if (!is.isClosed()) {
     try {
       is.close();
     } catch (IOException e) {
     }
   }
   WriteFinishedEvent e = new WriteFinishedEvent(t);
   t.getHttpContext().getServerImpl().addEvent(e);
 }