Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java @ 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 | aa1a43f5c03a |
children |
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();