Join GitHub today
The HTTP request library should include a default user agent #4552
By default, the http.js client does not include a User Agent when making requests. Per the HTTP specification, clients SHOULD include this information when making requests.
Furthermore, in the (unlikely) event that bugs are found in the Node implementation of, for example, multipart file transfer, a User Agent string could help servers detect the incorrect behavior and take an appropriate action.
The simplest possible default version would include the library name and the version number.
What's easy for people to do and what people actually do are two different things. It's easy for people to upload a LICENSE file to their repos, yet few people do. The practical result is that most requests using node.js do not include a User-Agent string.
I cannot think of a single other major http request library that does not provide a default user-agent string. Even Net::HTTP sends "Ruby" as the user agent if you don't specify one.
It also virtually guarantees the last-place finish of node.js in any sort of "which HTTP client are people using" comparison. In our case, we are trying to evaluate whether to write a helper API library using node.js. We tried grepping the server logs to figure out how many people are currently writing their own clients, and to talk to people currently using node to figure out what they'd want out of a library. In this case, grep turned up zero agents that looked like they might be using node.js, where comparable libraries in other languages rank in the hundreds of users.
The only high-level language where a default user agent is set in the HTTP request lib is Python, and only using urllib. (httplib does not.)
PHP doesn't. Several Java HTTP clients do not. Libcurl does not. It's a rather recent change that Ruby's Net::HTTP does, and it's not a change I would have agreed with, if I anyone asked me (but as I am not a Ruby user, I of course don't get a vote.)
This will not ever change in node. If you want a user-agent string, it is the easiest thing in the world to do in a userland module.