提交 b35d44bd 编写于 作者: B Brian Clozel

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
上级 20a286b4
......@@ -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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册