[Dive4elements-commits] [PATCH 7 of 8] Send errors as plaintext and not as pdf documents
Wald Commits
scm-commit at wald.intevation.org
Mon Apr 15 18:42:01 CEST 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1366043557 -7200
# Node ID aa1a43f5c03a647e7991d25614d49200cf491efd
# Parent e8b4c69967e2ab3bd6841109d04a3f40e3a5a16d
Send errors as plaintext and not as pdf documents
diff -r e8b4c69967e2 -r aa1a43f5c03a flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Mon Apr 15 18:27:37 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Mon Apr 15 18:32:37 2013 +0200
@@ -427,10 +427,22 @@
try {
byte [] buf = new byte[4096];
int r;
- resp.setHeader("Content-Disposition",
- "attachment;filename=flys-karte.pdf");
- resp.setContentType("application/pdf");
+ boolean checkedErrors = false;
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();
More information about the Dive4elements-commits
mailing list