Html程序  |  30行  |  625 B

<!DOCTYPE html>
<html>
<head>
<title>test ws split packet</title>
<script type="text/javascript">
var protocol = location.protocol.replace('http', 'ws');
var url = protocol + '//' + location.host + '/close-with-split-packet';

// Do connection test.
var ws = new WebSocket(url);

ws.onopen = function()
{
  // Close WebSocket connection once it is established.
  ws.close();
}

ws.onclose = function(event)
{
  // Check wasClean, then set proper title.
  if (event.wasClean && event.code === 3004 && event.reason === 'split test')
    document.title = 'PASS';
  else
    document.title = 'FAIL';
}

</script>
</head>
</html>