Socket
Socket
Sign inDemoInstall

ws

Package Overview
Dependencies
Maintainers
1
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ws - npm Package Compare versions

Comparing version 0.4.20 to 0.4.21

6

doc/ws.md

@@ -40,2 +40,8 @@ # ws

### Event: 'headers'
`function (headers) { }`
Emitted with the object of HTTP headers that are going to be written to the `Stream` as part of the handshake.
### Event: 'connection'

@@ -42,0 +48,0 @@

2

examples/fileapi/server.js

@@ -37,3 +37,3 @@ var WebSocketServer = require('../../').Server

incrementalPath += '/' + pieces.shift();
path.exists(incrementalPath, function(exists) {
fs.exists(incrementalPath, function(exists) {
if (!exists) fs.mkdir(incrementalPath, step);

@@ -40,0 +40,0 @@ else process.nextTick(step);

@@ -0,1 +1,7 @@

v0.4.21 - July 14th, 2012
=====================
* Emit error if server reponds with anything other than status code 101. [einaros]
* Added 'headers' event to server. [rauchg]
* path.exists moved to fs.exists. [blakmatrix]
v0.4.20 - June 26th, 2012

@@ -2,0 +8,0 @@ =====================

@@ -442,3 +442,9 @@ /*!

self.emit('error', error);
cleanupWebsocketResources.call(this, error);
});
(isNodeV4 ? agent : req).once('response', function(res) {
var error = new Error('unexpected server response (' + res.statusCode + ')');
self.emit('error', error);
cleanupWebsocketResources.call(this, error);
});
(isNodeV4 ? agent : req).once('upgrade', function(res, socket, upgradeHead) {

@@ -445,0 +451,0 @@ if (self.readyState == WebSocket.CLOSED) {

@@ -199,2 +199,5 @@ /*!

// allows external modification/inspection of handshake headers
self.emit('headers', headers);
socket.setTimeout(0);

@@ -201,0 +204,0 @@ socket.setNoDelay(true);

@@ -5,3 +5,3 @@ {

"description": "simple to use, blazing fast and thoroughly tested websocket client, server and console for node.js, up-to-date against RFC-6455",
"version": "0.4.20",
"version": "0.4.21",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -12,3 +12,4 @@ var http = require('http')

invalidKey: invalidRequestHandler,
closeAfterConnect: closeAfterConnectHandler
closeAfterConnect: closeAfterConnectHandler,
return401: return401
},

@@ -156,2 +157,13 @@ createServer: function(port, handler, cb) {

function return401(server, req, socket) {
var headers = [
'HTTP/1.1 401 Unauthorized'
, 'Content-type: text/html'
];
socket.write(headers.concat('', '').join('\r\n'));
socket.end();
}
/**

@@ -158,0 +170,0 @@ * Server object, which will do the actual emitting

@@ -187,3 +187,4 @@ var assert = require('assert')

describe('connection establishing', function() {
it('can disconnect before connection is established', function(done) {server.createServer(++port, function(srv) {
it('can disconnect before connection is established', function(done) {
server.createServer(++port, function(srv) {
var ws = new WebSocket('ws://localhost:' + port);

@@ -234,2 +235,15 @@ ws.terminate();

});
it('error is emitted if server aborts connection', function(done) {
server.createServer(++port, server.handlers.return401, function(srv) {
var ws = new WebSocket('ws://localhost:' + port);
ws.on('open', function() {
assert.fail('connect shouldnt be raised here');
});
ws.on('error', function() {
srv.close();
done();
});
});
});
});

@@ -236,0 +250,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc