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?
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?
As a side note, I'm liking the fluent API more and more!
Thanks,
Christopher