nodejs数据流+gzip

var http= require('http');

var fs = require('fs');

var zlib = require('zlib');

http.createServer((req,res)=>{

res.writeHead(200,{"content-encoding":"gzip"})

fs.createReadStream(__dirname+"/2019.pdf").pipe(zlib.createGzip()).pipe(res);

}).listen(8000);

你可能感兴趣的:(nodejs数据流+gzip)