/* ------------------------------------------------------------ */
  public void reset(boolean returnBuffers) {
    _parser.reset();
    if (returnBuffers) _parser.returnBuffers();
    _requestFields.clear();
    _request.recycle();

    _generator.reset(returnBuffers); // TODO maybe only release when low on resources
    _responseFields.clear();
    _response.recycle();

    _uri.clear();
  }
  /* ------------------------------------------------------------ */
  public void completeResponse() throws IOException {
    if (!_generator.isCommitted()) {
      _generator.setResponse(_response.getStatus(), _response.getReason());
      try {
        _generator.completeHeader(_responseFields, Generator.LAST);
      } catch (IOException io) {
        throw io;
      } catch (RuntimeException e) {
        LOG.warn("header full: " + e);
        LOG.debug(e);

        _response.reset();
        _generator.reset(true);
        _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500, null);
        _generator.completeHeader(_responseFields, Generator.LAST);
        _generator.complete();
        throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500);
      }
    }

    _generator.complete();
  }
  /* ------------------------------------------------------------ */
  public void commitResponse(boolean last) throws IOException {
    if (!_generator.isCommitted()) {
      _generator.setResponse(_response.getStatus(), _response.getReason());
      try {
        // If the client was expecting 100 continues, but we sent something
        // else, then we need to close the connection
        if (_expect100Continue && _response.getStatus() != 100) _generator.setPersistent(false);
        _generator.completeHeader(_responseFields, last);
      } catch (IOException io) {
        throw io;
      } catch (RuntimeException e) {
        LOG.warn("header full: " + e);

        _response.reset();
        _generator.reset(true);
        _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500, null);
        _generator.completeHeader(_responseFields, Generator.LAST);
        _generator.complete();
        throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500);
      }
    }
    if (last) _generator.complete();
  }