How to use the uws.http function in uws

To help you get started, we’ve selected a few uws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / uws / uws-tests.ts View on Github external
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']);
    }
});
github DefinitelyTyped / DefinitelyTyped / uws / uws-tests.ts View on Github external
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']);
    }
});

uws

## Go to [https://github.com/uNetworking/uWebSockets.js](https://github.com/uNetworking/uWebSockets.js).

Apache-2.0
Latest version published 4 years ago

Package Health Score

63 / 100
Full package analysis