This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 389b6b22a9 Remove unnecessary code
389b6b22a9 is described below
commit 389b6b22a9ce220ee76357094e0ddfa708244bf0
Author: Mark Thomas <[email protected]>
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 6784c4552a..2a8b132a3c 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -1469,6 +1469,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
@@ -1490,7 +1493,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;
@@ -2398,7 +2401,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
@@ -2415,12 +2419,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
@@ -2471,19 +2469,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: [email protected]
For additional commands, e-mail: [email protected]