Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project
This commit is contained in:
commit
cb778530a4
|
@ -43,8 +43,6 @@ import org.eclipse.jetty.websocket.WebSocket.OnTextMessage;
|
||||||
public class WebSocketConnectionD13 extends AbstractConnection implements WebSocketConnection
|
public class WebSocketConnectionD13 extends AbstractConnection implements WebSocketConnection
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(WebSocketConnectionD13.class);
|
private static final Logger LOG = Log.getLogger(WebSocketConnectionD13.class);
|
||||||
private static final boolean STRICT=Boolean.getBoolean("org.eclipse.jetty.websocket.STRICT");
|
|
||||||
private static final boolean BRUTAL=Boolean.getBoolean("org.eclipse.jetty.websocket.BRUTAL");
|
|
||||||
|
|
||||||
final static byte OP_CONTINUATION = 0x00;
|
final static byte OP_CONTINUATION = 0x00;
|
||||||
final static byte OP_TEXT = 0x01;
|
final static byte OP_TEXT = 0x01;
|
||||||
|
@ -645,24 +643,23 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc
|
||||||
{
|
{
|
||||||
byte[] array=buffer.array();
|
byte[] array=buffer.array();
|
||||||
|
|
||||||
if (STRICT)
|
if (isControlFrame(opcode) && buffer.length()>MAX_CONTROL_FRAME_PAYLOAD)
|
||||||
{
|
{
|
||||||
if (isControlFrame(opcode) && buffer.length()>MAX_CONTROL_FRAME_PAYLOAD)
|
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Control frame too large: " + buffer.length() + " > " + MAX_CONTROL_FRAME_PAYLOAD);
|
||||||
{
|
return;
|
||||||
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Control frame too large: " + buffer.length() + " > " + MAX_CONTROL_FRAME_PAYLOAD);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: check extensions for RSV bit(s) meanings
|
// TODO: check extensions for RSV bit(s) meanings
|
||||||
if ((flags&0x7)!=0)
|
if ((flags&0x7)!=0)
|
||||||
{
|
{
|
||||||
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"RSV bits set 0x"+Integer.toHexString(flags));
|
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"RSV bits set 0x"+Integer.toHexString(flags));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore all frames after error close
|
// Ignore all frames after error close
|
||||||
if (_closeCode!=0 && _closeCode!=CLOSE_NORMAL && opcode!=OP_CLOSE)
|
if (_closeCode!=0 && _closeCode!=CLOSE_NORMAL && opcode!=OP_CLOSE)
|
||||||
return;
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deliver frame if websocket is a FrameWebSocket
|
// Deliver frame if websocket is a FrameWebSocket
|
||||||
|
@ -786,7 +783,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc
|
||||||
|
|
||||||
case WebSocketConnectionD13.OP_TEXT:
|
case WebSocketConnectionD13.OP_TEXT:
|
||||||
{
|
{
|
||||||
if (STRICT && _opcode!=-1)
|
if (_opcode!=-1)
|
||||||
{
|
{
|
||||||
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode));
|
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode));
|
||||||
return;
|
return;
|
||||||
|
@ -827,7 +824,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc
|
||||||
|
|
||||||
case WebSocketConnectionD13.OP_BINARY:
|
case WebSocketConnectionD13.OP_BINARY:
|
||||||
{
|
{
|
||||||
if (STRICT && _opcode!=-1)
|
if (_opcode!=-1)
|
||||||
{
|
{
|
||||||
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode));
|
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Expected Continuation"+Integer.toHexString(opcode));
|
||||||
return;
|
return;
|
||||||
|
@ -857,8 +854,7 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (STRICT)
|
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad opcode 0x"+Integer.toHexString(opcode));
|
||||||
errorClose(WebSocketConnectionD13.CLOSE_PROTOCOL,"Bad opcode 0x"+Integer.toHexString(opcode));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -883,17 +879,16 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc
|
||||||
private void errorClose(int code, String message)
|
private void errorClose(int code, String message)
|
||||||
{
|
{
|
||||||
_connection.close(code,message);
|
_connection.close(code,message);
|
||||||
if (BRUTAL)
|
|
||||||
|
// Brutally drop the connection
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
_endp.close();
|
||||||
{
|
}
|
||||||
_endp.close();
|
catch (IOException e)
|
||||||
}
|
{
|
||||||
catch (IOException e)
|
LOG.warn(e.toString());
|
||||||
{
|
LOG.debug(e);
|
||||||
LOG.warn(e.toString());
|
|
||||||
LOG.debug(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue