summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/communication/UIInitHandler.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/server/src/com/vaadin/server/communication/UIInitHandler.java b/server/src/com/vaadin/server/communication/UIInitHandler.java
index cf0de8e9ee..d0b9aaaf15 100644
--- a/server/src/com/vaadin/server/communication/UIInitHandler.java
+++ b/server/src/com/vaadin/server/communication/UIInitHandler.java
@@ -17,7 +17,7 @@
package com.vaadin.server.communication;
import java.io.IOException;
-import java.io.OutputStreamWriter;
+import java.io.OutputStream;
import java.io.StringWriter;
import java.util.List;
import java.util.logging.Level;
@@ -114,18 +114,13 @@ public abstract class UIInitHandler extends SynchronizedRequestHandler {
// iOS 6 Safari requires this (#9732)
response.setHeader("Cache-Control", "no-cache");
- // NOTE! GateIn requires, for some weird reason, getOutputStream
- // to be used instead of getWriter() (it seems to interpret
- // application/json as a binary content type)
- OutputStreamWriter outputWriter = new OutputStreamWriter(
- response.getOutputStream(), "UTF-8");
- try {
- outputWriter.write(json);
- // NOTE GateIn requires the buffers to be flushed to work
- outputWriter.flush();
- } finally {
- outputWriter.close();
- }
+ byte[] b = json.getBytes("UTF-8");
+ response.setHeader("Content-Length", String.valueOf(b.length));
+
+ OutputStream outputStream = response.getOutputStream();
+ outputStream.write(b);
+ // NOTE GateIn requires the buffers to be flushed to work
+ outputStream.flush();
return true;
}