Use int instead of long for maxFramePayloadLength

This commit is contained in:
Trustin Lee 2012-05-30 17:21:51 -07:00
parent 67ee22e23a
commit 92f010d688
16 changed files with 22 additions and 22 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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));

View File

@ -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));

View File

@ -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));