summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2011-04-07 13:28:42 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2011-04-07 13:28:42 +0000
commitdb5c5d98256ebe089a215f0cf25b58a4e0e11cb6 (patch)
tree51ad6eadd7a7944913c4266938d8627cb00cff25 /src/com
parent36d703836e810df7c98982ad8c534ac09b3dd532 (diff)
downloadvaadin-framework-db5c5d98256ebe089a215f0cf25b58a4e0e11cb6.tar.gz
vaadin-framework-db5c5d98256ebe089a215f0cf25b58a4e0e11cb6.zip
merged [18158] (#6785) to 6.6
svn changeset:18160/svn branch:6.6
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 4cad1cc8e6..152fa81bb5 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -1358,33 +1358,24 @@ public abstract class AbstractCommunicationManager implements
protected String getRequestPayload(Request request) throws IOException {
int requestLength = request.getContentLength();
- if (requestLength <= 0) {
- /*
- * TODO Browsers as we know them, know how long XHR they are sending
- * and expose this in headers. However we have seen some -1 values
- * in logs. Wild guess is that it is some kind of bot that tries to
- * play well with ajax pages. Decide if we need to support those
- * requests. See #6401
- */
+ if (requestLength == 0) {
return null;
}
- byte[] buffer = new byte[requestLength];
+ ByteArrayOutputStream bout = requestLength <= 0 ? new ByteArrayOutputStream()
+ : new ByteArrayOutputStream(requestLength);
+
InputStream inputStream = request.getInputStream();
+ byte[] buffer = new byte[MAX_BUFFER_SIZE];
- 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) {
+ while (true) {
+ int read = inputStream.read(buffer);
+ if (read == -1) {
break;
}
-
- bytesRemaining -= bytesRead;
+ bout.write(buffer, 0, read);
}
-
- String result = new String(buffer, "utf-8");
+ String result = new String(bout.toByteArray(), "utf-8");
return result;
}