Mercurial > hg > digilib
changeset 1434:dcf933a2bd7e
more discarding.
author | robcast |
---|---|
date | Fri, 06 Nov 2015 14:30:56 +0100 |
parents | cc4e46818377 |
children | f4f4ce49c9ac |
files | servlet/src/main/java/digilib/servlet/ServletOps.java |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/servlet/src/main/java/digilib/servlet/ServletOps.java Thu Nov 05 20:19:38 2015 +0100 +++ b/servlet/src/main/java/digilib/servlet/ServletOps.java Fri Nov 06 14:30:56 2015 +0100 @@ -301,7 +301,9 @@ } /** - * Write image img to ServletResponse response. + * Write image img to ServletResponse response as data of mimeType. + * + * If mimeType is null, use heuristics for type. * * @param img * @param mimeType @@ -317,12 +319,11 @@ logger.error("No response!"); return; } - //logger.debug("sending to response: ("+ headersToString(response) + ") committed=" + response.isCommitted()); logger.debug("sending to response. committed=" + response.isCommitted()); try { /* - * determine content-type: if mime type is set use that otherwise - * if source is JPG then dest will be JPG else it's PNG + * determine the content-type: if mime type is set use that + * otherwise if source is JPG then dest will be JPG else it's PNG */ if (mimeType == null) { mimeType = img.getMimetype(); @@ -343,20 +344,23 @@ String respType = response.getContentType(); if (! mimeType.equals(respType)) { // this shouldn't happen - logger.error("Crap! ServletResponse lost content type! ct="+respType); - // TODO: would this help? + logger.error("Crap! ServletResponse lost content type! ["+respType+"] Aborting!"); + // TODO: would this even help? response.getOutputStream().close(); return; } + /* * write the image */ OutputStream outstream = response.getOutputStream(); img.writeImage(mimeType, outstream); + } catch (IOException e) { throw new ServletException("Error sending image:", e); - } - // TODO: should we: finally { img.dispose(); } + } finally { + img.dispose(); + } }