Use int instead of long for maxFramePayloadLength
This commit is contained in:
parent
67ee22e23a
commit
92f010d688
@ -32,7 +32,7 @@ import io.netty.util.VoidEnum;
|
||||
*/
|
||||
public class WebSocket00FrameDecoder extends ReplayingDecoder<WebSocketFrame, VoidEnum> {
|
||||
|
||||
private static final int DEFAULT_MAX_FRAME_SIZE = 16384;
|
||||
static final int DEFAULT_MAX_FRAME_SIZE = 16384;
|
||||
|
||||
private final long maxFrameSize;
|
||||
private boolean receivedClosingHandshake;
|
||||
@ -48,7 +48,7 @@ public class WebSocket00FrameDecoder extends ReplayingDecoder<WebSocketFrame, Vo
|
||||
* @param maxFrameSize
|
||||
* the maximum frame size to decode
|
||||
*/
|
||||
public WebSocket00FrameDecoder(long maxFrameSize) {
|
||||
public WebSocket00FrameDecoder(int maxFrameSize) {
|
||||
this.maxFrameSize = maxFrameSize;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocketFrame, We
|
||||
* Maximum length of a frame's payload. Setting this to an appropriate value for you application
|
||||
* helps check for denial of services attacks.
|
||||
*/
|
||||
public WebSocket08FrameDecoder(boolean maskedPayload, boolean allowExtensions, long maxFramePayloadLength) {
|
||||
public WebSocket08FrameDecoder(boolean maskedPayload, boolean allowExtensions, int maxFramePayloadLength) {
|
||||
super(State.FRAME_START);
|
||||
this.maskedPayload = maskedPayload;
|
||||
this.allowExtensions = allowExtensions;
|
||||
|
@ -70,7 +70,7 @@ public class WebSocket13FrameDecoder extends WebSocket08FrameDecoder {
|
||||
* Maximum length of a frame's payload. Setting this to an appropriate value for you application
|
||||
* helps check for denial of services attacks.
|
||||
*/
|
||||
public WebSocket13FrameDecoder(boolean maskedPayload, boolean allowExtensions, long maxFramePayloadLength) {
|
||||
public WebSocket13FrameDecoder(boolean maskedPayload, boolean allowExtensions, int maxFramePayloadLength) {
|
||||
super(maskedPayload, allowExtensions, maxFramePayloadLength);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
|
||||
protected final Map<String, String> customHeaders;
|
||||
|
||||
private final long maxFramePayloadLength;
|
||||
private final int maxFramePayloadLength;
|
||||
|
||||
/**
|
||||
* Base constructor
|
||||
@ -57,7 +57,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
* Maximum length of a frame's payload
|
||||
*/
|
||||
public WebSocketClientHandshaker(URI webSocketUrl, WebSocketVersion version, String subprotocol,
|
||||
Map<String, String> customHeaders, long maxFramePayloadLength) {
|
||||
Map<String, String> customHeaders, int maxFramePayloadLength) {
|
||||
this.webSocketUrl = webSocketUrl;
|
||||
this.version = version;
|
||||
expectedSubprotocol = subprotocol;
|
||||
@ -82,7 +82,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
/**
|
||||
* Returns the max length for any frame's payload
|
||||
*/
|
||||
public long getMaxFramePayloadLength() {
|
||||
public int getMaxFramePayloadLength() {
|
||||
return maxFramePayloadLength;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
* Maximum length of a frame's payload
|
||||
*/
|
||||
public WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, String subprotocol,
|
||||
Map<String, String> customHeaders, long maxFramePayloadLength) {
|
||||
Map<String, String> customHeaders, int maxFramePayloadLength) {
|
||||
super(webSocketURL, version, subprotocol, customHeaders, maxFramePayloadLength);
|
||||
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
* Maximum length of a frame's payload
|
||||
*/
|
||||
public WebSocketClientHandshaker08(URI webSocketURL, WebSocketVersion version, String subprotocol,
|
||||
boolean allowExtensions, Map<String, String> customHeaders, long maxFramePayloadLength) {
|
||||
boolean allowExtensions, Map<String, String> customHeaders, int maxFramePayloadLength) {
|
||||
super(webSocketURL, version, subprotocol, customHeaders, maxFramePayloadLength);
|
||||
this.allowExtensions = allowExtensions;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
* Maximum length of a frame's payload
|
||||
*/
|
||||
public WebSocketClientHandshaker13(URI webSocketURL, WebSocketVersion version, String subprotocol,
|
||||
boolean allowExtensions, Map<String, String> customHeaders, long maxFramePayloadLength) {
|
||||
boolean allowExtensions, Map<String, String> customHeaders, int maxFramePayloadLength) {
|
||||
super(webSocketURL, version, subprotocol, customHeaders, maxFramePayloadLength);
|
||||
this.allowExtensions = allowExtensions;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class WebSocketClientHandshakerFactory {
|
||||
*/
|
||||
public WebSocketClientHandshaker newHandshaker(
|
||||
URI webSocketURL, WebSocketVersion version, String subprotocol,
|
||||
boolean allowExtensions, Map<String, String> customHeaders, long maxFramePayloadLength) {
|
||||
boolean allowExtensions, Map<String, String> customHeaders, int maxFramePayloadLength) {
|
||||
if (version == WebSocketVersion.V13) {
|
||||
return new WebSocketClientHandshaker13(webSocketURL, version, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
|
||||
private final WebSocketVersion version;
|
||||
|
||||
private final long maxFramePayloadLength;
|
||||
private final int maxFramePayloadLength;
|
||||
|
||||
/**
|
||||
* Constructor specifying the destination web socket location
|
||||
@ -50,7 +50,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
*/
|
||||
protected WebSocketServerHandshaker(
|
||||
WebSocketVersion version, String webSocketUrl, String subprotocols,
|
||||
long maxFramePayloadLength) {
|
||||
int maxFramePayloadLength) {
|
||||
this.version = version;
|
||||
this.webSocketUrl = webSocketUrl;
|
||||
if (subprotocols != null) {
|
||||
@ -93,7 +93,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
/**
|
||||
* Returns the max length for any frame's payload.
|
||||
*/
|
||||
public long getMaxFramePayloadLength() {
|
||||
public int getMaxFramePayloadLength() {
|
||||
return maxFramePayloadLength;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
||||
* Maximum allowable frame payload length. Setting this value to your application's requirement may
|
||||
* reduce denial of service attacks using long data frames.
|
||||
*/
|
||||
public WebSocketServerHandshaker00(String webSocketURL, String subprotocols, long maxFramePayloadLength) {
|
||||
public WebSocketServerHandshaker00(String webSocketURL, String subprotocols, int maxFramePayloadLength) {
|
||||
super(WebSocketVersion.V00, webSocketURL, subprotocols, maxFramePayloadLength);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
|
||||
* Maximum allowable frame payload length. Setting this value to your application's requirement may
|
||||
* reduce denial of service attacks using long data frames.
|
||||
*/
|
||||
public WebSocketServerHandshaker08(String webSocketURL, String subprotocols, boolean allowExtensions, long maxFramePayloadLength) {
|
||||
public WebSocketServerHandshaker08(String webSocketURL, String subprotocols, boolean allowExtensions, int maxFramePayloadLength) {
|
||||
super(WebSocketVersion.V08, webSocketURL, subprotocols, maxFramePayloadLength);
|
||||
this.allowExtensions = allowExtensions;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
|
||||
* Maximum allowable frame payload length. Setting this value to your application's requirement may
|
||||
* reduce denial of service attacks using long data frames.
|
||||
*/
|
||||
public WebSocketServerHandshaker13(String webSocketURL, String subprotocols, boolean allowExtensions, long maxFramePayloadLength) {
|
||||
public WebSocketServerHandshaker13(String webSocketURL, String subprotocols, boolean allowExtensions, int maxFramePayloadLength) {
|
||||
super(WebSocketVersion.V13, webSocketURL, subprotocols, maxFramePayloadLength);
|
||||
this.allowExtensions = allowExtensions;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class WebSocketServerHandshakerFactory {
|
||||
|
||||
private final boolean allowExtensions;
|
||||
|
||||
private final long maxFramePayloadLength;
|
||||
private final int maxFramePayloadLength;
|
||||
|
||||
/**
|
||||
* Constructor specifying the destination web socket location
|
||||
@ -68,7 +68,7 @@ public class WebSocketServerHandshakerFactory {
|
||||
*/
|
||||
public WebSocketServerHandshakerFactory(
|
||||
String webSocketURL, String subprotocols, boolean allowExtensions,
|
||||
long maxFramePayloadLength) {
|
||||
int maxFramePayloadLength) {
|
||||
this.webSocketURL = webSocketURL;
|
||||
this.subprotocols = subprotocols;
|
||||
this.allowExtensions = allowExtensions;
|
||||
|
@ -74,7 +74,7 @@ public class WebSocketServerHandshaker00Test {
|
||||
ChannelBuffer buffer = ChannelBuffers.copiedBuffer("^n:ds[4U", Charset.defaultCharset());
|
||||
req.setContent(buffer);
|
||||
|
||||
WebSocketServerHandshaker00 handsaker = new WebSocketServerHandshaker00("ws://example.com/chat", "chat", Long.MAX_VALUE);
|
||||
WebSocketServerHandshaker00 handsaker = new WebSocketServerHandshaker00("ws://example.com/chat", "chat", Integer.MAX_VALUE);
|
||||
handsaker.handshake(channelMock, req);
|
||||
|
||||
Assert.assertEquals("ws://example.com/chat", res.getValue().getHeader(Names.SEC_WEBSOCKET_LOCATION));
|
||||
|
@ -67,7 +67,7 @@ public class WebSocketServerHandshaker08Test {
|
||||
req.setHeader(Names.SEC_WEBSOCKET_PROTOCOL, "chat, superchat");
|
||||
req.setHeader(Names.SEC_WEBSOCKET_VERSION, "8");
|
||||
|
||||
WebSocketServerHandshaker08 handsaker = new WebSocketServerHandshaker08("ws://example.com/chat", "chat", false, Long.MAX_VALUE);
|
||||
WebSocketServerHandshaker08 handsaker = new WebSocketServerHandshaker08("ws://example.com/chat", "chat", false, Integer.MAX_VALUE);
|
||||
handsaker.handshake(channelMock, req);
|
||||
|
||||
Assert.assertEquals("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", res.getValue().getHeader(Names.SEC_WEBSOCKET_ACCEPT));
|
||||
|
@ -66,7 +66,7 @@ public class WebSocketServerHandshaker13Test {
|
||||
req.setHeader(Names.SEC_WEBSOCKET_ORIGIN, "http://example.com");
|
||||
req.setHeader(Names.SEC_WEBSOCKET_PROTOCOL, "chat, superchat");
|
||||
req.setHeader(Names.SEC_WEBSOCKET_VERSION, "13");
|
||||
WebSocketServerHandshaker13 handsaker = new WebSocketServerHandshaker13("ws://example.com/chat", "chat", false, Long.MAX_VALUE);
|
||||
WebSocketServerHandshaker13 handsaker = new WebSocketServerHandshaker13("ws://example.com/chat", "chat", false, Integer.MAX_VALUE);
|
||||
handsaker.handshake(channelMock, req);
|
||||
|
||||
Assert.assertEquals("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", res.getValue().getHeader(Names.SEC_WEBSOCKET_ACCEPT));
|
||||
|
Loading…
Reference in New Issue
Block a user