This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push: new 193489d0f4 Remove unnecessary code 193489d0f4 is described below commit 193489d0f441336870fc560883c013fefeb1fa99 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Dec 13 16:06:24 2024 +0000 Remove unnecessary code --- .../apache/catalina/servlets/DefaultServlet.java | 27 +++++----------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java b/java/org/apache/catalina/servlets/DefaultServlet.java index a357d2ea23..3df4749d72 100644 --- a/java/org/apache/catalina/servlets/DefaultServlet.java +++ b/java/org/apache/catalina/servlets/DefaultServlet.java @@ -1459,6 +1459,9 @@ public class DefaultServlet extends HttpServlet { /** * Parse the range header. + * <p> + * The caller is required to have confirmed that the requested resource exists and is a file before calling this + * method. * * @param request The servlet request we are processing * @param response The servlet response we are creating @@ -1480,7 +1483,7 @@ public class DefaultServlet extends HttpServlet { return FULL; } - if (!"GET".equals(request.getMethod()) || !determineRangeRequestsApplicable(resource)) { + if (!"GET".equals(request.getMethod()) || !isRangeRequestsSupported()) { // RFC 9110 - Section 14.2: GET is the only method for which range handling is defined. // Otherwise MUST ignore a Range header field return FULL; @@ -2339,7 +2342,8 @@ public class DefaultServlet extends HttpServlet { /** - * Check if the if-range condition is satisfied. + * Check if the if-range condition is satisfied. The calling method is required to ensure a Range header is present + * and that Range requests are supported for the current resource. * * @param request The servlet request we are processing * @param response The servlet response we are creating @@ -2356,12 +2360,6 @@ public class DefaultServlet extends HttpServlet { String resourceETag = generateETag(resource); long resourceLastModified = resource.getLastModified(); - String rangeHeader = request.getHeader("Range"); - if (rangeHeader == null || !determineRangeRequestsApplicable(resource)) { - // Simply ignore If-Range header field - return true; - } - Enumeration<String> headerEnum = request.getHeaders("If-Range"); if (!headerEnum.hasMoreElements()) { // If-Range is not present @@ -2412,19 +2410,6 @@ public class DefaultServlet extends HttpServlet { return true; } - /** - * Determines if range-request is applicable for the target resource. - * <p> - * Subclass have an opportunity to customize by overriding this method. - * - * @param resource the target resource - * - * @return <code>true</code> only if range requests is supported by both the server and the target resource. - */ - protected boolean determineRangeRequestsApplicable(WebResource resource) { - return isRangeRequestsSupported() && resource.isFile() && resource.exists(); - } - /** * Provides the entity tag (the ETag header) for the given resource. Intended to be over-ridden by custom * DefaultServlet implementations that wish to use an alternative format for the entity tag. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org