As a tangent I want to reduce this code pattern which is duplicated no less
than six times:

        // determine the release version from packaged version info
        final VersionInfo vi = VersionInfo.loadVersionInfo
            ("org.apache.http.client",
HttpClientBuilder.class.getClassLoader());
        final String release = (vi != null) ?
            vi.getRelease() : VersionInfo.UNAVAILABLE;
        HttpProtocolParams.setUserAgent(params,
                "Apache-HttpClient/" + release + " (java 1.5)");

into a new method:

    setUserAgent(params, "Apache-HttpClient", "org.apache.http.client",
HttpClientBuilder.class);

    public static void setUserAgent(HttpParams params, String name, String
pkg, Class<?> cls) {
        final VersionInfo vi = VersionInfo.loadVersionInfo(pkg,
cls.getClassLoader());
        final String release = (vi != null) ? vi.getRelease() :
VersionInfo.UNAVAILABLE;
        HttpProtocolParams.setUserAgent(params, name + "/" + release + "
(java 1.5)");
    }

The question is: where in Core should it go?

I see that HttpProtocolParams is deprecated, so it cannot go in there.

So... where?

Gary

On Fri, Nov 16, 2012 at 9:12 PM, Jon Moore <[email protected]> wrote:

> On Fri, Nov 16, 2012 at 8:42 PM, Gary Gregory <[email protected]>
> wrote:
> > 1) do nothing
> > 2) User-Agent: Apache-HttpClient/4.2.1 (Java 1.5+ min)
> > 3) User-Agent: Apache-HttpClient/4.2.1 (Java/1.6.0_35)
> >
> > 3 is in the spirit of the JRE's HttpURLConnection FWIW.
>
> If you're collecting votes, I'd vote for #3, but I have no objections
> to any of these--all are reasonable.
>
> Jon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
E-Mail: [email protected] | [email protected]
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to