The problem with sending binary data native http module

For example here is the minimum code that shows the error:
require('http').createServer(function (req, res) {
 var test = new Buffer(4);
 test.writeUInt32BE(2886731494, 0);

 Res. writeHead(200, {'Content-Type': 'text/html'});
Res. end(test);
}).listen(81, myServerIp);


Code should return response with binary data, while Content-Length is set exactly to 4 bytes. This is the goal.
Problem:
The server is running on linux(gentoo);
the client(the browser) running under linux(ubunta, suse), the answer is given in 1-3 ms,
client on windows 7, the answer for 220-240 ms.

The results are similar on different machines. On linux fast on Windows slow.

When floor task will work equally fast regardless of the OS of the client:
— If the same server is running on windows.
— If the same task to implement for example apache/php — echo pack('N', 2886731494);
— If res.end(test.toString()), but the length of the header will be 4 bytes, and 8. What is not acceptable.
— If the client tries to use http 1.0 (unfortunately there is no possibility forcedly to specify in the answer)

Who that will advise? ;)

PS. browsers probyvali different measurements of speed were taken from garbage and analogues.
October 8th 19 at 02:49
1 answer
October 8th 19 at 02:51
While I set the nginx server helps. But still I would like to hear smart people.

Find more questions by tags Node.js