@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException { String contentType = req.getContentType(); if (Strings.isNullOrEmpty(contentType)) { resp.setStatus(SC_BAD_REQUEST); } else { TimeMetric timeMetric = metricFactory.timer("JMAP-upload-post"); try { uploadHandler.handle(contentType, req.getInputStream(), getMailboxSession(req), resp); } catch (IOException e) { if (e instanceof EOFException) { LOGGER.info("An upload has been canceled before the end", e); } else { internalServerError(resp, e); } } catch (MailboxException e) { internalServerError(resp, e); } finally { timeMetric.stopAndPublish(); } } }