INT-4135: Ignore case check for HTTP Content-Type

JIRA: https://jira.spring.io/browse/INT-4135

The incoming `Content-Type` HTTP header can be in any arbitrary case.

Fix `DefaultHttpHeaderMapper` `Content-Type` header re-mapping to the `MessageHeaders.CONTENT_TYPE` via `equalsIgnoreCase()` comparison

**Cherry-pick to 4.3.x**
This commit is contained in:
Artem Bilan
2016-10-10 11:30:15 -04:00
committed by Gary Russell
parent c75b72ffe7
commit a82bca653b
2 changed files with 10 additions and 1 deletions

View File

@@ -462,7 +462,7 @@ public class DefaultHttpHeaderMapper implements HeaderMapper<HttpHeaders>, BeanF
if (logger.isDebugEnabled()) {
logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value));
}
if (CONTENT_TYPE.equals(name)) {
if (CONTENT_TYPE.equalsIgnoreCase(name)) {
name = MessageHeaders.CONTENT_TYPE;
}
this.setMessageHeader(target, name, value);

View File

@@ -581,6 +581,15 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
assertEquals(MediaType.valueOf("text/plain"), httpHeaders.getContentType());
}
@Test
public void testContentTypeInboundHeader() throws Exception {
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.inboundMapper();
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE.toLowerCase(), "text/plain");
Map<String, ?> result = mapper.toHeaders(headers);
assertEquals(MediaType.valueOf("text/plain"), result.get(MessageHeaders.CONTENT_TYPE));
}
public static class TestClass {