First let me show my code.
http=require("http");
fs=require("fs");
var server=http.createServer(function(req,res){
var readStream=fs.createReadStream("1.jpg");
readStream.on("data",function(data){
res.write(data);
});
readStream.on("end",function(data){
res.write("this string seems not to be sent","utf8");
res.end("end","utf8");
});
});
server.listen(3000);
I created a readStream of picture 1.jpg and then sent data stream. After the "end" event was fired, I sent a string "this string seems not to be sent". I didn't specify a content-length in headers.
On the client side, I actually got 1.jpg correctly. But I didn't receive the string. I guess there must be something that marks the end of stream. If so, what the mark is? how it works?
I know that assigning transfer-encoding with "chunked" is a way to send data whose length is uncertain, but my safari shows the response headers are:
Connection keep-alive
Transfer-Encoding Identity