public void reset(boolean preserveCookies) { if (!preserveCookies) reset(); else { ArrayList<String> cookieValues = new ArrayList<String>(5); Enumeration<String> vals = _fields.getValues(HttpHeader.SET_COOKIE.asString()); while (vals.hasMoreElements()) cookieValues.add(vals.nextElement()); reset(); for (String v : cookieValues) _fields.add(HttpHeader.SET_COOKIE, v); } }
/* ------------------------------------------------------------ */ 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(); }