Skip to content

Simple utility to generate a websocket handshake hash/response.

License

Notifications You must be signed in to change notification settings

vutran/websocket-handshake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple utility to generate a websocket handshake hash/response.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published