Mercurial > dive4elements > river
diff gwt-client/src/main/java/org/dive4elements/river/client/server/ExportServiceImpl.java @ 7486:6b278187ed9d
Removed charset encoding on outs. They are mainly binary data which simply should be proxied through.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 31 Oct 2013 19:03:57 +0100 |
parents | 6efa25f97f7e |
children | e469d9939a52 |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/ExportServiceImpl.java Thu Oct 31 18:34:10 2013 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/ExportServiceImpl.java Thu Oct 31 19:03:57 2013 +0100 @@ -8,8 +8,10 @@ package org.dive4elements.river.client.server; +import java.io.InputStreamReader; import java.io.OutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -45,7 +47,7 @@ logger.info("ExportServiceImpl.doGet"); try { - OutputStream out = resp.getOutputStream(); + final OutputStream out = resp.getOutputStream(); String url = getServletContext().getInitParameter("server-url"); String uuid = req.getParameter("uuid"); @@ -55,7 +57,7 @@ String locale = req.getParameter("locale"); String km = req.getParameter("km"); String fn = name + "." + type; - String enc = req.getParameter("encoding"); + final String enc = req.getParameter("encoding"); resp.setHeader("Content-Disposition", "attachment;filename=" + fn); @@ -76,21 +78,27 @@ uuid, mode, type, attr); HttpClient client = new HttpClientImpl(url, locale); - // Set out encoding if specified. if (enc != null) { + InputStreamReader in = new InputStreamReader( + client.collectionOut(request, uuid, mode), + "UTF-8"); try { - client.setOutEncoding( - java.nio.charset.Charset.forName(enc)); + OutputStreamWriter encOut = new OutputStreamWriter(out, enc); + char buf [] = new char[4096]; + int c; + while ((c = in.read(buf, 0, buf.length)) >= 0) { + encOut.write(buf, 0, c); + } + out.flush(); } - catch(java.nio.charset.UnsupportedCharsetException e) { - logger.warn("Unsupported encoding: " + enc); + finally { + in.close(); } } - - client.collectionOut(request, uuid, mode, out); - - out.close(); - out.flush(); + else { // Just copy thru. + client.collectionOut(request, uuid, mode, out); + out.flush(); + } } catch (IOException ioe) { logger.error(ioe, ioe);