diff options
author | Artur Signell <artur.signell@itmill.com> | 2009-04-16 06:01:59 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2009-04-16 06:01:59 +0000 |
commit | e586ebe1d19e2168fd5ab8888376c9a95f317b47 (patch) | |
tree | e60955ca33b9c59181fabb9e8756978df42b936f /src/com/itmill/toolkit/terminal/gwt/server | |
parent | 7a46af6a48c27c19093b518106cced1e8751702f (diff) | |
download | vaadin-framework-e586ebe1d19e2168fd5ab8888376c9a95f317b47.tar.gz vaadin-framework-e586ebe1d19e2168fd5ab8888376c9a95f317b47.zip |
Merged fix for #2847 - Problem running on Oracle OAS10g
svn changeset:7430/svn branch:6.0
Diffstat (limited to 'src/com/itmill/toolkit/terminal/gwt/server')
-rw-r--r-- | src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index cd4fcae766..cfedb42dc4 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -612,17 +612,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, boolean success = true; if (request.getContentLength() > 0) { - - byte[] buffer = new byte[request.getContentLength()]; - ServletInputStream inputStream = request.getInputStream(); - int totalBytesRead = 0; - int bytesRead; - while ((bytesRead = inputStream.read(buffer, totalBytesRead, - MAX_BUFFER_SIZE)) != -1) { - totalBytesRead += bytesRead; - } - - String changes = new String(buffer, "utf-8"); + String changes = readRequest(request); // Manage bursts one by one final String[] bursts = changes.split(VAR_BURST_SEPARATOR); @@ -780,6 +770,39 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, return success; } + /** + * Reads the request data from the HttpServletRequest and returns it + * converted to an UTF-8 string. + * + * @param request + * @return + * @throws IOException + */ + private static String readRequest(HttpServletRequest request) + throws IOException { + + int requestLength = request.getContentLength(); + + byte[] buffer = new byte[requestLength]; + ServletInputStream inputStream = request.getInputStream(); + + int bytesRemaining = requestLength; + while (bytesRemaining >= 0) { + int bytesToRead = Math.min(bytesRemaining, MAX_BUFFER_SIZE); + int bytesRead = inputStream.read(buffer, requestLength + - bytesRemaining, bytesToRead); + if (bytesRead == -1) { + break; + } + + bytesRemaining -= bytesRead; + } + + String result = new String(buffer, "utf-8"); + + return result; + } + public class ErrorHandlerErrorEvent implements ErrorEvent, Serializable { private final Throwable throwable; |