INT-3488: Map Content-Disposition HTTP header

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

The `Transfer-Encoding` has been remained as unmapped for the `DefaultHttpHeaderMapper.inboundMapper()`
This commit is contained in:
Artem Bilan
2014-08-02 15:01:33 +03:00
committed by Gary Russell
parent 507fd42d01
commit d0cf1a8080
3 changed files with 27 additions and 6 deletions

View File

@@ -109,6 +109,8 @@ public class HttpProxyScenarioTests {
RestTemplate template = Mockito.spy(new RestTemplate());
final String contentDispositionValue = "attachment; filename=\"test.txt\"";
Mockito.doAnswer(new Answer<ResponseEntity<?>>() {
@Override
public ResponseEntity<?> answer(InvocationOnMock invocation) throws Throwable {
@@ -122,6 +124,7 @@ public class HttpProxyScenarioTests {
MultiValueMap<String, String> responseHeaders = new LinkedMultiValueMap<String, String>(httpHeaders);
responseHeaders.set("Connection", "close");
responseHeaders.set("Content-Disposition", contentDispositionValue);
return new ResponseEntity<Object>(responseHeaders, HttpStatus.OK);
}
}).when(template).exchange(Mockito.any(URI.class), Mockito.any(HttpMethod.class),
@@ -138,6 +141,7 @@ public class HttpProxyScenarioTests {
assertNull(response.getHeaderValue("If-Modified-Since"));
assertNull(response.getHeaderValue("If-Unmodified-Since"));
assertEquals("close", response.getHeaderValue("Connection"));
assertEquals(contentDispositionValue, response.getHeader("Content-Disposition"));
Message<?> message = this.checkHeadersChannel.receive(2000);
MessageHeaders headers = message.getHeaders();

View File

@@ -520,7 +520,7 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
httpHeaders.set("Transfer-Encoding", "chunked");
Map<String, ?> messageHeaders = mapper.toHeaders(httpHeaders);
assertEquals(0, messageHeaders.size());
assertEquals(1, messageHeaders.size());
}
@@ -673,6 +673,7 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
assertEquals(0, messageHeaders.size());
}
@Test
public void testInt2995IfModifiedSince() throws Exception{
Date ifModifiedSince = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
@@ -688,4 +689,14 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
assertEquals(c.getTimeInMillis(), headers.getIfModifiedSince());
}
@Test
public void testContentDispositionHeader() throws Exception{
HttpHeaders headers = new HttpHeaders();
String headerValue = "attachment; filename=\"test.txt\"";
headers.set("Content-Disposition", headerValue);
Map<String, Object> messageHeaders = DefaultHttpHeaderMapper.outboundMapper().toHeaders(headers);
assertEquals(1, messageHeaders.size());
assertEquals(headerValue, messageHeaders.get("Content-Disposition"));
}
}