Add 'User-Agent' header to CLI REST calls

Update the InitializrService so that a 'SpringBootCli' User-Agent header
is sent with each request. This should allow the server-side code to
gracefully evolve the JSON format if needed.

Fixes gh-1869
This commit is contained in:
Phillip Webb
2014-11-10 21:44:35 -08:00
parent 3c9476fbe6
commit 6027b2405c
2 changed files with 27 additions and 0 deletions

View File

@@ -141,6 +141,8 @@ class InitializrService {
private CloseableHttpResponse execute(HttpUriRequest request, Object url,
String description) {
try {
request.addHeader("User-Agent", "SpringBootCli/"
+ getClass().getPackage().getImplementationVersion());
return getHttp().execute(request);
}
catch (IOException ex) {