1
gzip으로 응답을 보내려고하고 있지만 다음 예에서 Chrome에 "Hello S/I m S k getting"가 표시됩니다. 대신 "Hello World!"node.js 스트리밍 gzip http 응답
var http = require('http'),
zlib = require('zlib');
http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Type': 'html/text',
'Transfer-Encoding': 'chunked',
'Content-Encoding': 'gzip',
'Content-Type': 'text/html;charset=UTF-8'
});
zlib.gzip("Hello", function(_, result) {
res.write(result);
});
zlib.gzip(" World", function(_, result) {
res.write(result);
});
zlib.gzip('!', function(_, result) {
res.end(result);
});
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
감사하지만, 내가 설명한 문제와 어떻게 관련이 있는지 확실하지 않습니다. 더 자세한 정보를 제공해 주시겠습니까? –
당신은 다음에 청크 인코딩이있을 것이라고 말하면서 HTTP 클라이언트에 거짓말을하고 있지만 그렇게하지는 않습니다. 표준에 따라 HTTP 스트림을 구성하지 않으면 좋은 결과를 기대할 수 없습니다. –