I create resources on the node server and bind ETag to each of them. I am using the method found in this question What encoding should I use to correctly generate cryptography ETag in nodeJS? to generate ETags. However, when I make a HEAD request at the command line using curl, for example:
$ curl -i -u username:password -X HEAD http://localhost:3000/aResource/0
answer
HTTP/1.1 200 OK X-Powered-By: Express ETag: "1a37c148692f92ad6c97887f77c873e6" Content-Type: text/plain Date: Sat, 26 Oct 2013 01:06:28 GMT Connection: keep-alive ^C $
and I have to specifically press Control-C to see the command line again. On the other hand, I find this strange, because the way the HEAD request is processed is through app.head on the node, and after authentication I call the function:
function serveResourceEtag(req, res) { console.log("Following route through HEAD"); var anID = parseInt(req.params[resourceID], "utf8"); if (anID < serverData.resourceEtags.length) { res.writeHead (200, {"ETag": "\"" + serverData.resourceEtags[anID] + "\"", "Content-Type": "text/plain"}); res.end(); } else { res.writeHead (404, {"Content-Type": "text/plain"}); res.end(); } };
In other words, although I have res.end (); the team in the end, the transfer for some reason did not stop. As far as I understand, the HEAD request should have the same header as the GET request. The difference with a GET is that in the case of HEAD we do not have a GET request body. Can you say that this is a problem?
source share