parent
2a15b5a895
commit
82ec06ad34
|
@ -61,7 +61,8 @@ public class JsonpTransportHandler extends AbstractHttpReceivingTransportHandler
|
|||
|
||||
@Override
|
||||
protected String[] readMessages(ServerHttpRequest request) throws IOException {
|
||||
if (MediaType.APPLICATION_FORM_URLENCODED.equals(request.getHeaders().getContentType())) {
|
||||
MediaType contentType = request.getHeaders().getContentType();
|
||||
if ((contentType != null) && MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(contentType)) {
|
||||
MultiValueMap<String, String> map = this.formConverter.read(null, request);
|
||||
String d = map.getFirst("d");
|
||||
return (StringUtils.hasText(d)) ? getObjectMapper().readValue(d, String[].class) : null;
|
||||
|
|
|
@ -73,6 +73,18 @@ public class HttpReceivingTransportHandlerTests extends AbstractHttpRequestTest
|
|||
assertEquals("ok", this.servletResponse.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-10621
|
||||
|
||||
@Test
|
||||
public void readMessagesJsonpFormEncodedWithEncoding() throws Exception {
|
||||
this.servletRequest.setContent("d=[\"x\"]".getBytes("UTF-8"));
|
||||
this.servletRequest.setContentType("application/x-www-form-urlencoded;charset=UTF-8");
|
||||
handleRequest(new JsonpTransportHandler());
|
||||
|
||||
assertEquals(200, this.servletResponse.getStatus());
|
||||
assertEquals("ok", this.servletResponse.getContentAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readMessagesBadContent() throws Exception {
|
||||
this.servletRequest.setContent("".getBytes("UTF-8"));
|
||||
|
|
Loading…
Reference in New Issue