Simplify String concatenation

This commit is contained in:
stsypanov
2019-03-14 12:37:08 +02:00
committed by Juergen Hoeller
parent 9d2e7ced89
commit 29f382b04e
6 changed files with 19 additions and 32 deletions

View File

@@ -403,12 +403,11 @@ public class MockHttpServletRequest implements HttpServletRequest {
private void updateContentTypeHeader() {
if (StringUtils.hasLength(this.contentType)) {
StringBuilder sb = new StringBuilder(this.contentType);
if (!this.contentType.toLowerCase().contains(CHARSET_PREFIX) &&
StringUtils.hasLength(this.characterEncoding)) {
sb.append(";").append(CHARSET_PREFIX).append(this.characterEncoding);
String value = this.contentType;
if (StringUtils.hasLength(this.characterEncoding) && !this.contentType.toLowerCase().contains(CHARSET_PREFIX)) {
value += ';' + CHARSET_PREFIX + this.characterEncoding;
}
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, sb.toString(), true);
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, value, true);
}
}