From 42c4b2097bc955ca18107c449e04f0d5d5683ca3 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 20 May 2013 15:08:48 +0300 Subject: Use "\0" instead of "|" as a push message delimiter (#11692) Used with TrackMessageSizeInterceptor and with client-to-server Websocket message splitting (see #11648) The original issue that the delimiter can not appear in the message (unescaped) is apparently fixed in Atmosphere 1.0.13 Also ensure the max size of a websocket fragment in bytes does not exceed the buffer size (#11842) Change-Id: I768524bb54a5b8b9479dc7bda821256bd843dc52 --- .../com/vaadin/shared/ApplicationConstants.java | 4 -- .../vaadin/shared/communication/PushConstants.java | 46 ++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 shared/src/com/vaadin/shared/communication/PushConstants.java (limited to 'shared/src') diff --git a/shared/src/com/vaadin/shared/ApplicationConstants.java b/shared/src/com/vaadin/shared/ApplicationConstants.java index fc4abd1988..04cba79c0c 100644 --- a/shared/src/com/vaadin/shared/ApplicationConstants.java +++ b/shared/src/com/vaadin/shared/ApplicationConstants.java @@ -83,8 +83,4 @@ public class ApplicationConstants implements Serializable { * Name of the parameter used to transmit the CSRF token. */ public static final String CSRF_TOKEN_PARAMETER = "v-csrfToken"; - - public static final int WEBSOCKET_BUFFER_SIZE = 65536; - - public static final char WEBSOCKET_MESSAGE_DELIMITER = '|'; } diff --git a/shared/src/com/vaadin/shared/communication/PushConstants.java b/shared/src/com/vaadin/shared/communication/PushConstants.java new file mode 100644 index 0000000000..2d63621c12 --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/PushConstants.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.communication; + +import java.io.Serializable; + +/** + * Shared constants used by push. + * + * @since 7.1 + * @author Vaadin Ltd + */ +public class PushConstants implements Serializable { + + /** + * The size, in bytes, of the receiving buffer used by some servers. + */ + public static final int WEBSOCKET_BUFFER_SIZE = 65536; + + /** + * The maximum size, in characters, of a websocket message fragment. + * This is a conservative maximum chosen so that the size in bytes will not + * exceed {@link PushConstants#WEBSOCKET_BUFFER_SIZE} given a UTF-8 encoded + * message. + */ + public static final int WEBSOCKET_FRAGMENT_SIZE = WEBSOCKET_BUFFER_SIZE / 4 - 1; + + /** + * The character used to mark message boundaries when messages may be split + * into multiple fragments. + */ + public static final char MESSAGE_DELIMITER = '\0'; +} -- cgit v1.2.3