Fix inputstream reading for HTTP range requests

Prior to this commit, range requests would be served by
ResourceHttpRequestHandler by partially reading the inputstream of
static resources. In case of resources contained in ZIP/JAR containers,
InputStreams may not fill the entire read buffer when calling
`inputStream.read(byte[])`. This was the case when using Spring Boot's
ZipInflaterInputStream - this would then not read the entire file
content and would close the response without writing the expected body
length indicated in the "Content-Length" header.

This commit makes sure that the whole resource is read.

Issue: SPR-13661
This commit is contained in:
Brian Clozel 2015-11-24 21:36:22 +01:00
parent 20a286b4d6
commit b35d44bd4c
1 changed files with 1 additions and 1 deletions

View File

@ -574,7 +574,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
out.write(buffer, 0, (int) bytesToCopy);
bytesToCopy = 0;
}
if (bytesRead < buffer.length) {
if (bytesRead == -1) {
break;
}
}