You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by lu...@apache.org on 2004/06/17 19:30:09 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method GetMethod.java
luetzkendorf 2004/06/17 10:30:09
Modified: src/webdav/server/org/apache/slide/webdav/method
GetMethod.java
Log:
Fix for Bug that return data if If-Range header requires that
workaround for Microsofts non quoted ETags
Revision Changes Path
1.45 +29 -44 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java
Index: GetMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- GetMethod.java 25 Apr 2004 17:33:50 -0000 1.44
+++ GetMethod.java 17 Jun 2004 17:30:09 -0000 1.45
@@ -26,7 +26,6 @@
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.text.ParseException;
import java.util.Date;
import java.util.Enumeration;
import java.util.StringTokenizer;
@@ -43,7 +42,6 @@
import org.apache.slide.content.RevisionDescriptorNotFoundException;
import org.apache.slide.content.RevisionNotFoundException;
import org.apache.slide.structure.LinkedObjectNotFoundException;
-import org.apache.slide.structure.ObjectNode;
import org.apache.slide.util.Configuration;
import org.apache.slide.webdav.WebdavException;
import org.apache.slide.webdav.WebdavServletConfig;
@@ -194,7 +192,7 @@
// Then we must get object contents ...
- ObjectNode object = structure.retrieve(slideToken, resourcePath);
+ structure.retrieve(slideToken, resourcePath);
NodeRevisionDescriptors revisionDescriptors =
content.retrieve(slideToken, resourcePath);
@@ -232,9 +230,8 @@
("Last-Modified",
revisionDescriptor.getLastModified().toString());
- if ( ((ranges == null) || (ranges.isEmpty()))
- && (req.getHeader("Range") == null) ) {
-
+ if ( ((ranges == null) || (ranges.isEmpty())) ) {
+ // full content response
resp.setContentType
(revisionDescriptor.getContentType());
resp.setContentLength
@@ -248,10 +245,6 @@
}
} else {
-
- if ((ranges == null) || (ranges.isEmpty()))
- return;
-
// Partial content response.
resp.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
@@ -588,35 +581,36 @@
private Vector parseRange(HttpServletRequest request,
HttpServletResponse response,
ResourceInfo resourceInfo)
- throws IOException {
+ throws IOException
+ {
+
+ // Retrieving the range header (if any is specified)
+ String rangeHeader = request.getHeader("Range");
+ if (rangeHeader == null) {
+ return null;
+ }
// Checking If-Range
String headerValue = request.getHeader("If-Range");
if (headerValue != null) {
-
- String eTag = getETag(resourceInfo, true);
+ headerValue = headerValue.trim();
+
long lastModified = resourceInfo.date;
- Date date = null;
-
- // Parsing the HTTP Date
- for (int i = 0; (date == null) && (i < formats.length); i++) {
- try {
- synchronized (formats[i]) {
- date = formats[i].parse(headerValue);
- }
- } catch (ParseException e) {
- ;
- }
- }
-
+ Date date = parseHttpDate(headerValue);
if (date == null) {
-
// If the ETag the client gave does not match the entity
// etag, then the entire entity is returned.
- if (!eTag.equals(headerValue.trim()))
- return null;
-
+ if (headerValue.startsWith("\"")) {
+ if (!getETag(resourceInfo, true).equals(headerValue)) {
+ return null;
+ }
+ } else {
+ // HACK Some clients does not quote the ETag properly
+ if (!getETagValue(resourceInfo, true).equals(headerValue)) {
+ return null;
+ }
+ }
} else {
// If the timestamp of the entity the client got is older than
@@ -624,21 +618,13 @@
// is returned.
if (lastModified > (date.getTime() + 1000))
return null;
-
}
-
}
long fileLength = resourceInfo.length;
- if (fileLength == 0)
- return null;
+ if (fileLength == 0) return null;
- // Retrieving the range header (if any is specified
- String rangeHeader = request.getHeader("Range");
-
- if (rangeHeader == null)
- return null;
// bytes is the only range unit supported (and I don't see the point
// of adding new ones).
if (!rangeHeader.startsWith("bytes")) {
@@ -646,7 +632,6 @@
(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
return null;
}
-
rangeHeader = rangeHeader.substring(6);
@@ -720,7 +705,7 @@
// ------------------------------------------------------ Range Inner Class
- private class Range {
+ private static class Range {
public long start;
public long end;
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org