npm.io
0.1.1 • Published 9 years ago

websocket-handshake

Licence
MIT
Version
0.1.1
Deps
0
Vulns
0
Weekly
0

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

Keywords