// -------------------- Jk handler implementation -------------------- // Jk Handler mehod public int invoke(Msg msg, MsgContext ep) throws IOException { if (ep.isLogTimeEnabled()) ep.setLong(MsgContext.TIMER_PRE_REQUEST, System.currentTimeMillis()); Request req = ep.getRequest(); Response res = req.getResponse(); if (log.isDebugEnabled()) log.debug("Invoke " + req + " " + res + " " + req.requestURI().toString()); res.setNote(epNote, ep); ep.setStatus(MsgContext.JK_STATUS_HEAD); RequestInfo rp = req.getRequestProcessor(); rp.setStage(Constants.STAGE_SERVICE); try { adapter.service(req, res); } catch (Exception ex) { log.info("Error servicing request " + req, ex); } if (ep.getStatus() != MsgContext.JK_STATUS_CLOSED) { res.finish(); } req.updateCounters(); req.recycle(); res.recycle(); ep.recycle(); if (ep.getStatus() == MsgContext.JK_STATUS_ERROR) { return ERROR; } ep.setStatus(MsgContext.JK_STATUS_NEW); rp.setStage(Constants.STAGE_KEEPALIVE); return OK; }
/** * Close the output buffer. This tries to calculate the response size if the response has not been * committed yet. * * @throws IOException An underlying IOException occurred */ @Override public void close() throws IOException { if (closed) return; if (suspended) return; if ((!coyoteResponse.isCommitted()) && (coyoteResponse.getContentLengthLong() == -1)) { // If this didn't cause a commit of the response, the final content // length can be calculated if (!coyoteResponse.isCommitted()) { coyoteResponse.setContentLength(bb.getLength()); } } doFlush(false); closed = true; coyoteResponse.finish(); }