Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ws.on('close', function() {
if (++ssl_disconnections == 519) {
ssl.close();
}
});
});
httpsServer.listen(3001);
/**
* HTTP module.
*/
const document: Buffer = Buffer.from('Hello world!');
const server: http.Server = WebSocket.http.createServer(
(req: http.IncomingMessage, res: http.ServerResponse): void => {
if (req.method === 'POST') {
const body: Buffer[] = [];
req.on('data', (chunk: Buffer) => {
body.push(Buffer.from(chunk));
}).on('end', () => {
res.end('You posted me this: ' + Buffer.concat(body).toString());
});
// handle some GET url
} else if (req.url === '/') {
res.end(document);
} else {
res.end('Unknown request by: ' + req.headers['user-agent']);
}
});
ws.on('close', function() {
if (++ssl_disconnections == 519) {
ssl.close();
}
});
});
httpsServer.listen(3001);
/**
* HTTP module.
*/
const document: Buffer = Buffer.from('Hello world!');
const server: http.Server = WebSocket.http.createServer(
(req: http.IncomingMessage, res: http.ServerResponse): void => {
if (req.method === 'POST') {
const body: Buffer[] = [];
req.on('data', (chunk: Buffer) => {
body.push(Buffer.from(chunk));
}).on('end', () => {
res.end('You posted me this: ' + Buffer.concat(body).toString());
});
// handle some GET url
} else if (req.url === '/') {
res.end(document);
} else {
res.end('Unknown request by: ' + req.headers['user-agent']);
}
});