Skip to content

Commit 2dd2b71

Browse files
committed
ShallowEtagHeaderFilter supports Servlet 3.1's setContentLengthLong as well
Issue: SPR-12097 (cherry picked from commit 0c32d66)
1 parent f418e6e commit 2dd2b71

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
*
4747
* @author Arjen Poutsma
4848
* @author Rossen Stoyanchev
49+
* @author Juergen Hoeller
4950
* @since 3.0
5051
*/
5152
public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
@@ -246,6 +247,17 @@ public void setContentLength(int len) {
246247
}
247248
}
248249

250+
// Overrides Servlet 3.1 setContentLengthLong(long) at runtime
251+
public void setContentLengthLong(long len) {
252+
if (len > Integer.MAX_VALUE) {
253+
throw new IllegalArgumentException("Content-Length exceeds ShallowEtagHeaderFilter's maximum (" +
254+
Integer.MAX_VALUE + "): " + len);
255+
}
256+
if (len > this.content.capacity()) {
257+
this.content.resize((int) len);
258+
}
259+
}
260+
249261
@Override
250262
public void setBufferSize(int size) {
251263
if (size > this.content.capacity()) {

0 commit comments

Comments
 (0)