Bug 62687 - WarURLConnection always returns -1 from getContentLength() and getContentLengthLong() which causes a 416 when request includes a Range header
Summary: WarURLConnection always returns -1 from getContentLength() and getContentLeng...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.5.x-trunk
Hardware: All All
: P2 normal with 5 votes (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-07 01:45 UTC by Douglas Paul
Modified: 2018-09-12 00:34 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Paul 2018-09-07 01:45:37 UTC
WarURLConnection doesn't override the default implementations of getContentLength() and getContentLengthLong(), so it always returns -1.

In the context of a Spring Boot application, this has the effect of causing requests that have a Range header to return a 416 Range Not Satisfiable.

I originally reported this bug against Spring Boot (https://github.com/spring-projects/spring-boot/issues/14306) but the developers there suggested I report it here.

Specifically, Andy Wilkinson suggested that WarUrlConnection should override getContentLength() and getContentLengthLong() to delegate them to wrappedJarUrlConnection as is done for getLastModified(). (See bug 61125.)
Comment 1 Remy Maucherat 2018-09-11 09:24:17 UTC
Ok, this is reasonable. The fix will be in 9.0.13 and 8.5.35.
Comment 2 Douglas Paul 2018-09-12 00:34:55 UTC
Excellent, thanks!