0.1.1 • Published 8 years ago
websocket-handshake v0.1.1
websocket-handshake
Simple utility to generate a websocket handshake hash/response.
Install
$ npm install --save websocket-handshake
Usage
Import the module
const { getResponseHash, getResponseHeaders } = require('websocket-handshake');
Create the handshake response hash
const hash = getResponseHash('dGhlIHNhbXBsZSBub25jZQ==');
// => s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Create the handshake response headers
const request = { ... }; // instance of http.ServerRequest
const headers = getResponseHeaders(request);
// => HTTP/1.1 101 Switching Protocols
// Upgrade: websocket
// Connection: Upgrade
// Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
License
MIT © Vu Tran