Consistent support for Charset/StandardCharsets in UriUtils etc

Issue: SPR-15613
This commit is contained in:
Juergen Hoeller
2017-06-12 15:51:45 +02:00
parent 14161d1dbf
commit 3ae84d6dd8
15 changed files with 244 additions and 171 deletions

View File

@@ -19,7 +19,6 @@ package org.springframework.test.web.servlet.request;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.security.Principal;
@@ -698,17 +697,12 @@ public class MockHttpServletRequestBuilder
}
private void addRequestParams(MockHttpServletRequest request, MultiValueMap<String, String> map) {
try {
for (Entry<String, List<String>> entry : map.entrySet()) {
for (String value : entry.getValue()) {
value = (value != null) ? UriUtils.decode(value, "UTF-8") : null;
request.addParameter(UriUtils.decode(entry.getKey(), "UTF-8"), value);
}
for (Entry<String, List<String>> entry : map.entrySet()) {
for (String value : entry.getValue()) {
value = (value != null ? UriUtils.decode(value, StandardCharsets.UTF_8) : null);
request.addParameter(UriUtils.decode(entry.getKey(), StandardCharsets.UTF_8), value);
}
}
catch (UnsupportedEncodingException ex) {
// shouldn't happen
}
}
private MultiValueMap<String, String> parseFormData(final MediaType mediaType) {