From e586ebe1d19e2168fd5ab8888376c9a95f317b47 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 16 Apr 2009 06:01:59 +0000 Subject: Merged fix for #2847 - Problem running on Oracle OAS10g svn changeset:7430/svn branch:6.0 --- .../terminal/gwt/server/CommunicationManager.java | 45 ++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'src/com/itmill/toolkit/terminal/gwt/server') 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; -- cgit v1.2.3