contentLength support for Resource decoding
Expose the known content length, if known, in the InputStreamResource returned by ResourceHttpMessageConverter or ResourceDecoder. See gh-24292
This commit is contained in:
committed by
Rossen Stoyanchev
parent
e3e7d90415
commit
e96b71acf3
@@ -80,10 +80,12 @@ public class ResourceHttpMessageConverterTests {
|
||||
inputMessage.getHeaders().setContentType(MediaType.IMAGE_JPEG);
|
||||
inputMessage.getHeaders().setContentDisposition(
|
||||
ContentDisposition.builder("attachment").filename("yourlogo.jpg").build());
|
||||
inputMessage.getHeaders().setContentLength(123);
|
||||
Resource actualResource = converter.read(InputStreamResource.class, inputMessage);
|
||||
assertThat(actualResource).isInstanceOf(InputStreamResource.class);
|
||||
assertThat(actualResource.getInputStream()).isEqualTo(body);
|
||||
assertThat(actualResource.getFilename()).isEqualTo("yourlogo.jpg");
|
||||
assertThat(actualResource.contentLength()).isEqualTo(123);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user