Mercurial > dive4elements > river
changeset 5752:b6f8fd50269b
Check for errors based on the return code instead of hackish parsing
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 18 Apr 2013 10:42:40 +0200 |
parents | 37c0b35e0fb5 |
children | 6f166b8b5eda |
files | flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java |
diffstat | 1 files changed, 9 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Thu Apr 18 10:42:07 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Thu Apr 18 10:42:40 2013 +0200 @@ -427,22 +427,16 @@ try { byte [] buf = new byte[4096]; int r; - boolean checkedErrors = false; + if (result < 200 || result >= 300) { + resp.setContentType("text/plain"); + } else { + // Only send content disposition and filename content + // type when we have a pdf + resp.setHeader("Content-Disposition", + "attachment;filename=flys-karte.pdf"); + resp.setContentType("application/pdf"); + } while ((r = in.read(buf)) >= 0) { - if (!checkedErrors) { - checkedErrors = true; - String header = new String(buf, "UTF-8"); - if (header.contains("Error while generating PDF:")) { - resp.setContentType("text/plain"); - } else { - // Only send content disposition and filename content - // type when we have a pdf - resp.setHeader("Content-Disposition", - "attachment;filename=flys-karte.pdf"); - resp.setContentType("application/pdf"); - } - - } out.write(buf, 0, r); } out.flush();