From 2c977a31349848826596ef510993a45217145ccc Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 2 Jun 2016 15:40:09 -0700 Subject: [PATCH] GUACAMOLE-44: Explicitly define and document the magic 6048-byte blob within ArrayBufferWriter. Allow the blob size to be overridden. --- .../main/webapp/modules/ArrayBufferWriter.js | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/ArrayBufferWriter.js b/guacamole-common-js/src/main/webapp/modules/ArrayBufferWriter.js index 8f33dd2be..2fc3e938b 100644 --- a/guacamole-common-js/src/main/webapp/modules/ArrayBufferWriter.js +++ b/guacamole-common-js/src/main/webapp/modules/ArrayBufferWriter.js @@ -61,6 +61,20 @@ Guacamole.ArrayBufferWriter = function(stream) { } + /** + * The maximum length of any blob sent by this Guacamole.ArrayBufferWriter, + * in bytes. Data sent via + * {@link Guacamole.ArrayBufferWriter#sendData|sendData()} which exceeds + * this length will be split into multiple blobs. As the Guacamole protocol + * limits the maximum size of any instruction or instruction element to + * 8192 bytes, and the contents of blobs will be base64-encoded, this value + * should only be increased with extreme caution. + * + * @type {Number} + * @default {@link Guacamole.ArrayBufferWriter.DEFAULT_BLOB_LENGTH} + */ + this.blobLength = Guacamole.ArrayBufferWriter.DEFAULT_BLOB_LENGTH; + /** * Sends the given data. * @@ -71,13 +85,13 @@ Guacamole.ArrayBufferWriter = function(stream) { var bytes = new Uint8Array(data); // If small enough to fit into single instruction, send as-is - if (bytes.length <= 6048) + if (bytes.length <= guac_writer.blobLength) __send_blob(bytes); // Otherwise, send as multiple instructions else { - for (var offset=0; offset