boot icon indicating copy to clipboard operation
boot copied to clipboard

Set user agent on Maven download requests

Open danielcompton opened this issue 7 years ago • 1 comments
trafficstars

Problem Description

Currently Boot doesn't set a User Agent for Aether to use when it is downloading files. Therefore, Aether uses the default User-Agent header Aether. It would be useful for Boot to set a User-Agent header to enable Maven repository owners and corporate users with middleware proxies to help debug any issues that arise.

You can set this by setting the system property aether.connector.userAgent:

Prior art

Leiningen does it like this:

https://github.com/technomancy/leiningen/blob/cc44d42ff6382be9f5bca2054c6f6fca2606b691/leiningen-core/src/leiningen/core/main.clj#L388-L397

c.f. https://github.com/technomancy/leiningen/pull/637, https://github.com/technomancy/leiningen/issues/636

Examples

A few examples of user agents that different systems provide:

  • Apache-HttpClient/4.5.3 (Java/1.8.0_162)
  • Leiningen/2.8.1 (Java OpenJDK 64-Bit Server VM; Linux 4.10.0-38-generic; amd64)
  • Apache-Maven/3.5.3 (Java 1.8.0_171; Linux 4.4.0-127-generic)

Possible solutions

Setting the system property to something like Boot/2.7.2 (Java 1.8.0_171; Linux 4.4.0-127-generic) seems like it could work.

You could also provide a configuration object with this information in it, but this wouldn't be as easy and I don't think it is necessary to be this flexible.

danielcompton avatar Jun 06 '18 22:06 danielcompton

Seems like a good idea, I'd be open to a PR. Thanks for bringing this up.

alandipert avatar Aug 05 '18 03:08 alandipert