私はexpressでhttpサーバを作成します。私は、URLを取得するためのnetcatを使用する場合res.writeHead()を無効にする方法は、出力の前に余分な番号を出力しますか?
router.get('/', function(req, res, next) {
// req.socket.setTimeout(Infinity);
res.writeHead(200, {
'Content-Type': 'text/plain; charset=utf-8', // <- Important headers
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
});
res.write('hell');
res.write('world');
res.end();
// res.write('\n\n');
// response = res;
});
: 以下は、サーバーコードです。 出力はこの
GET /sse HTTP/1.1
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/plain; charset=utf-8
Cache-Control: no-cache
Expires: 0
Connection: keep-alive
Keep-Alive: timeout=5, max=97
Date: Fri, 30 Jun 2017 11:50:00 GMT
Transfer-Encoding: chunked
4
hell
5
world
0
私の質問のようなもので、すべてのres.write前に、常に数がある理由()?そして、その数はres.writeの出力の長さと思われます。
番号を削除するにはどうすればよいですか?
https://en.wikipedia.org/wiki/Chunked_transfer_encoding – robertklep