long responseTime = System.currentTimeMillis() - startTime;
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {        if (ZimbraLog.perf.isDebugEnabled()) {            ThreadLocalData.reset();        }        int len = req.getContentLength();        byte[] buffer;        if (len == -1) {            buffer = readUntilEOF(req.getInputStream());        } else {            buffer = new byte[len];            readFully(req.getInputStream(), buffer, 0, len);        }        if (ZimbraLog.soap.isDebugEnabled()) {            ZimbraLog.soap.debug("SOAP request:\n" + new String(buffer, "utf8"));        }        long startTime = sSoapStopWatch.start();                HashMap context = new HashMap();        context.put(SERVLET_REQUEST, req);        context.put(SoapEngine.REQUEST_IP, req.getRemoteAddr());                    //checkAuthToken(req.getCookies(), context);        Element envelope = null;        try {            envelope = mEngine.dispatch(req.getRequestURI(), buffer, context);        } catch (Throwable e) {            if (e instanceof OutOfMemoryError) {                Zimbra.halt("handler exception", e);            }            ZimbraLog.soap.warn("handler exception", e);            Element fault = SoapProtocol.Soap12.soapFault(ServiceException.FAILURE(e.toString(), e));            envelope = SoapProtocol.Soap12.soapEnvelope(fault);        }        SoapProtocol soapProto = SoapProtocol.determineProtocol(envelope);        int statusCode = soapProto.hasFault(envelope) ?                HttpServletResponse.SC_INTERNAL_SERVER_ERROR : HttpServletResponse.SC_OK;                byte[] soapBytes = envelope.toUTF8();        if (ZimbraLog.soap.isDebugEnabled()) {            ZimbraLog.soap.debug("SOAP response: \n" + new String(soapBytes, "utf8"));        }                resp.setContentType(soapProto.getContentType());        resp.setBufferSize(soapBytes.length + 2048);        resp.setContentLength(soapBytes.length);        resp.setStatus(statusCode);        resp.getOutputStream().write(soapBytes);        sSoapStopWatch.stop(startTime);                // If perf logging is enabled, track server response times        if (ZimbraLog.perf.isDebugEnabled()) {            long responseTime = System.currentTimeMillis() - startTime;            String responseName = soapProto.getBodyElement(envelope).getName();            ZimbraPerf.writeResponseStats(responseName, responseTime,                ThreadLocalData.getDbTime(), ThreadLocalData.getStatementCount());        }    }