我有一個客戶端的NodeJS是類似於HTTP的NodeJS後 - 的GZip
var options = {
hostname: 'www.google.com',
port: 80,
path: '/upload',
method: 'POST'
};
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write data to request body
req.write('data\n');
req.write('data\n');
req.end();
有什麼辦法,使在gzip壓縮在所有req.write數據元素?
我認爲他們想要另一種方式...發送一個gzipped請求正文。這將需要設置標題:{'Content-Encoding':'gzip'}'並使用Gzip流和管道req來代替。 – mscdex