Skip to content

Commit 6ff459a

Browse files
author
Stephane Landelle
committed
Only extract charset from Content-Type header when it wasn't set explicitly
1 parent a1b8674 commit 6ff459a

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/main/java/com/ning/http/client/RequestBuilderBase.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -648,18 +648,20 @@ private void executeSignatureCalculator() {
648648
}
649649

650650
private void computeRequestCharset() {
651-
try {
652-
final String contentType = request.headers.getFirstValue("Content-Type");
653-
if (contentType != null) {
654-
final String charset = AsyncHttpProviderUtils.parseCharset(contentType);
655-
if (charset != null) {
656-
// ensure that if charset is provided with the Content-Type header,
657-
// we propagate that down to the charset of the Request object
658-
request.charset = charset;
651+
if (request.charset == null) {
652+
try {
653+
final String contentType = request.headers.getFirstValue("Content-Type");
654+
if (contentType != null) {
655+
final String charset = AsyncHttpProviderUtils.parseCharset(contentType);
656+
if (charset != null) {
657+
// ensure that if charset is provided with the Content-Type header,
658+
// we propagate that down to the charset of the Request object
659+
request.charset = charset;
660+
}
659661
}
662+
} catch (Throwable e) {
663+
// NoOp -- we can't fix the Content-Type or charset from here
660664
}
661-
} catch (Throwable e) {
662-
// NoOp -- we can't fix the Content-Type or charset from here
663665
}
664666
}
665667

0 commit comments

Comments
 (0)