hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: User-Agent
Date Sat, 18 Feb 2017 09:56:50 GMT
On Fri, 2017-02-17 at 09:38 -0800, Gary Gregory wrote:
> On Fri, Feb 17, 2017 at 2:43 AM, Oleg Kalnichevski <olegk@apache.org>
> wrote:
> 
...

> > Gary
> > 
> > It should be quite easy to plug in a custom protocol interceptor
> > that
> > generates a user agent header with additional runtime details.
> > However,
> > I am not sure it would really make sense to change the format used
> > by
> > default. I hope you agree.
> > 
> 
> Sounds OK. Any hints as to where to allow this to be plugged in
> exactly?
> 
> Gary
> 

Something like that should do the job, should not it?

---
VersionInfo clientVersion = VersionInfo.loadVersionInfo("org.apache.http.client", Testing.class.getClassLoader());
VersionInfo coreVersion = VersionInfo.loadVersionInfo("org.apache.http", Testing.class.getClassLoader());
String javaVersion = System.getProperty("java.version");

String agentInfo = String.format("HttpClient/%s HttpCore/%s Java/%s)",
        clientVersion.getRelease(),
        coreVersion.getRelease(),
        javaVersion);

CloseableHttpClient client = HttpClientBuilder.create()
        .setUserAgent(agentInfo)
        .build();
---

Oleg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message