hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: Log misleading for User-Agent
Date Sat, 17 Nov 2012 17:49:09 GMT
On Sat, Nov 17, 2012 at 10:25 AM, Oleg Kalnichevski <olegk@apache.org>wrote:

> On Fri, 2012-11-16 at 21:19 -0500, Gary Gregory wrote:
> > 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
> >
>
> Gary
>
> HttpClient trunk is in a state of flux right now. But please bear with
> me a little while longer. I think HttpCore 4.3-alpha1 should be ready
> quite soon. Once HttpClient trunk picks up new APIs from HttpCore 4.3 a
> lot of things should become clearer (or so I would like to hope).
>
> ---
> I think this particular bit belongs to HttpClientBuilder and it should
> only be used once. Another place for it might be HttpClientUtils.
>

But neither of these classes are in the Core. The 3 (not 6) code
duplications are in both the regular and async clients such that the core
is the only place to put it to avoid duplication. Am I missing something?
-
org.apache.http.impl.nio.client.DefaultHttpAsyncClient.setDefaultHttpParams(HttpParams)
-
org.apache.http.impl.client.builder.HttpClientBuilder.setUserAgent(HttpParams,
String, String, Class<?>)
-
org.apache.http.impl.client.DefaultHttpClient.setDefaultHttpParams(HttpParams)


> I am also in favor of option 3. Besides, we might even have something
> that combine option 2 and 3
>
> 3) User-Agent: Apache-HttpClient/4.2.1 (Java 1.5 compatible;
> Java/1.6.0_35)
>

Hm... but HttpClient is also "compatible" with Java 1.6, that's why I
considered the "minimum" verbiage:

3) User-Agent: Apache-HttpClient/4.2.1 (Java 1.5 minimum; Java/1.6.0_35)

Gary


> ---
> I double-checked JIRA settings once again and found out that I had had
> used an older (or different) account of yours. Could you please try
> again and let me know of the name of the account you have been using if
> it still does not work?
>

My account is all set now, thank you. I marked
HTTPCLIENT-1260<https://issues.apache.org/jira/browse/HTTPCLIENT-1260>as
resolved for 4.3-aplpha1. I'll have to find a way to get rid of my old
account to avoid further confusion.

Gary

>
> Oleg
>
> > On Fri, Nov 16, 2012 at 9:12 PM, Jon Moore <jonm@apache.org> wrote:
> >
> > > On Fri, Nov 16, 2012 at 8:42 PM, Gary Gregory <garydgregory@gmail.com>
> > > 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: dev-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: dev-help@hc.apache.org
> > >
> > >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message