Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BBC70108FA for ; Sun, 10 Nov 2013 16:46:00 +0000 (UTC) Received: (qmail 66681 invoked by uid 500); 10 Nov 2013 16:45:59 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 65436 invoked by uid 500); 10 Nov 2013 16:45:54 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 65366 invoked by uid 99); 10 Nov 2013 16:45:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Nov 2013 16:45:49 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [217.150.250.48] (HELO kalnich.nine.ch) (217.150.250.48) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Nov 2013 16:45:34 +0000 Received: from [192.168.42.106] (unknown [213.55.184.227]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by kalnich.nine.ch (Postfix) with ESMTPSA id 0B5AAB80038 for ; Sun, 10 Nov 2013 17:45:13 +0100 (CET) Message-ID: <1384101912.3761.17.camel@ubuntu> Subject: Re: Some observations with HTTP Client 4.3.1 From: Oleg Kalnichevski To: HttpClient User Discussion Date: Sun, 10 Nov 2013 17:45:12 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Sat, 2013-11-09 at 23:15 +0100, Christopher BROWN wrote: > Hello, > > Porting some HTTP Client 4.2 code to non-deprecated equivalents in 4.3.1, I > noticed a small change between: > > // MultipartEntity > entity.addPart("field", new StringBody(values)); > > ...and: > > // MultipartEntityBuilder > entityBuilder.addTextBody("field", values); > > The former, when no charset is specified, defaults to ASCII, due to: > > @Deprecated > public StringBody(final String text) throws UnsupportedEncodingException { > this(text, "text/plain", Consts.ASCII); > } > > The latter, without a charset, defaults to ISO-8859-1 from what I can see. > This broke a unit test in my code, but was easily fixed. I'm guessing it > makes more sense to use ISO-8859-1 because it seems to be the default in > practice on the Internet. Is that correct? > Hi Christopher I do not have a reference handy, but I am fairly confident that the MIME spec actually defines ISO-8859-1 as the default content for textual content bodies. The old implementation was simply incorrect. > Also, I built HTTP client from source using the command: > > mvn -Dmaven.compiler.target=1.7 package > > ...which generated class files in 1.7 format (slightly optimized if I'm to > believe Oracle/Sun docs). However, the user agent still shows > "Apache-HttpClient/4.3.1 (java 1.5)" as the User-Agent. Is it useful to > hard-code the Java version like this, because it doesn't match the compiler > option or the runtime environment? > The initial intent was to state the minimal JRE compatibility level for HttpClient of a particular version. This has been causing a fair deal confusion though. The way the default user-agent id is generated is very likely to change in 4.4. Feel free to raise a JIRA for this issue if you want to keep track of its resolution. > As a side note, I'm liking the fluent API more and more! > I am glad to hear that. Usually such major API changes tend to generate more rants and outright insults than gratitude or even constructive criticism. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org