example/client.js
function startServer() {
    http.createServer((req, res) => {
        const fileName = __dirname + path.sep + new Date().getTime() + '.png';

        req.on('end', () => {
            res.writeHead(200);
            res.end();

            fs.stat(fileName, function(error, stat) {
              console.log(
                'Stored file ' + fileName +
                ' with size ' + stat.size +
                ', headers: ' + JSON.stringify(req.headers)
              );
              fs.unlinkSync(fileName);
            });
        });
        req.pipe(fs.createWriteStream(fileName));
    }).listen(DEF_CLIENT_PORT);

    console.log("Client server running on port 8124");
}
function startServer() {
    http.createServer((req, res) => {
        const fileName = __dirname + path.sep + new Date().getTime() + '.png';

        req.on('end', () => {
            res.writeHead(200);
            res.end();

            fs.stat(fileName, function(error, stat) {
              console.log(
                'Stored file ' + fileName +
                ' with size ' + stat.size +
                ', headers: ' + JSON.stringify(req.headers)
              );
              fs.unlinkSync(fileName);
            });
        });
        req.pipe(fs.createWriteStream(fileName));
    }).listen(DEF_CLIENT_PORT);

    console.log("Client server running on port 8124");
}
function startServer ( ) { http . createServer ( ( req , res ) => { const fileName = __dirname + path . sep + new Date ( ) . getTime ( ) + '.png' ; req . on ( 'end' , ( ) => { res . writeHead ( 200 ) ; res . end ( ) ; fs . stat ( fileName , function ( error , stat ) { console . log ( 'Stored file ' + fileName + ' with size ' + stat . size + ', headers: ' + JSON . stringify ( req . headers ) ) ; fs . unlinkSync ( fileName ) ; } ) ; } ) ; req . pipe ( fs . createWriteStream ( fileName ) ) ; } ) . listen ( DEF_CLIENT_PORT ) ; console . log ( "Client server running on port 8124" ) ; }
Start client HTTP server.
Start client HTTP server .