ShallowEtagHeaderFilter supports Servlet 3.1's setContentLengthLong as well

Issue: SPR-12097
This commit is contained in:
Juergen Hoeller 2014-08-19 20:17:42 +02:00
parent 110be33337
commit 0c32d66cbd
1 changed files with 12 additions and 0 deletions

View File

@ -46,6 +46,7 @@ import org.springframework.web.util.WebUtils;
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @since 3.0
*/
public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
@ -246,6 +247,17 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
}
}
// Overrides Servlet 3.1 setContentLengthLong(long) at runtime
public void setContentLengthLong(long len) {
if (len > Integer.MAX_VALUE) {
throw new IllegalArgumentException("Content-Length exceeds ShallowEtagHeaderFilter's maximum (" +
Integer.MAX_VALUE + "): " + len);
}
if (len > this.content.capacity()) {
this.content.resize((int) len);
}
}
@Override
public void setBufferSize(int size) {
if (size > this.content.capacity()) {