This repository has been archived by the owner. It is now read-only.

The HTTP request library should include a default user agent #4552

Closed
kevinburke opened this Issue Jan 9, 2013 · 7 comments

Comments

Projects
None yet
5 participants
@kevinburke

kevinburke commented Jan 9, 2013

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.

User-Agent: node-http/0.9.5
@mikeal

This comment has been minimized.

Member

mikeal commented Jan 9, 2013

the client is not the node programming language, the client is the application built w/ node.js and it should set the header appropriately.

@isaacs

This comment has been minimized.

isaacs commented Jan 9, 2013

Node doesn't set a default user agent on purpose. If you want such a thing, put it in your app. It's easy to add headers.

@isaacs isaacs closed this Jan 9, 2013

@kevinburke

This comment has been minimized.

kevinburke commented Jan 10, 2013

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.

@stevegraham

This comment has been minimized.

stevegraham commented Jan 10, 2013

@luk-

This comment has been minimized.

luk- commented Jan 10, 2013

All of the involvement that Twilio employees have had in the node & js communities and you're relying on server logs to gauge interest in a node library? Just write it.

@stevegraham

This comment has been minimized.

stevegraham commented Jan 10, 2013

@st-luke there are several in the community e.g. https://github.com/stevegraham/twilio-js, but twilio has a major case of NIH syndrome.

@isaacs

This comment has been minimized.

isaacs commented Jan 10, 2013

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.) curl(1) does, but the command-line curl program is an app, not a library.

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.

thewisenerd added a commit to thewisenerd/openshift-jsonp that referenced this issue Dec 21, 2015

proxy-request: do not remove user-agent
node.js' request library does not generate a user-agent (ref: nodejs/node-v0.x-archive#4552).

Signed-off-by: thewisenerd <thewisenerd@protonmail.com>

thewisenerd added a commit to thewisenerd/openshift-jsonp that referenced this issue Dec 21, 2015

proxy-request: do not remove user-agent
node.js' request library does not generate a user-agent (ref: nodejs/node-v0.x-archive#4552).

Signed-off-by: thewisenerd <thewisenerd@protonmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.