]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
web/filenode: add Accept-Ranges and ETag (for immutable files) headers to GET responses
authorBrian Warner <warner@allmydata.com>
Wed, 29 Oct 2008 01:01:03 +0000 (18:01 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 29 Oct 2008 01:01:03 +0000 (18:01 -0700)
src/allmydata/web/filenode.py

index b96ba175a5bd7073033a00d31539b10f65854f6e..472f782c329ff3d4b6aed2a4304612689418ded2 100644 (file)
@@ -10,7 +10,7 @@ from allmydata.interfaces import ExistingChildError
 from allmydata.monitor import Monitor
 from allmydata.immutable.upload import FileHandle
 from allmydata.immutable.filenode import LiteralFileNode
-from allmydata.util import log
+from allmydata.util import log, base32
 
 from allmydata.web.common import text_plain, WebError, IClient, RenderMixin, \
      boolean_of_arg, get_arg, should_create_intermediate_directories
@@ -353,6 +353,13 @@ class FileDownloader(rend.Page):
         assert isinstance(filesize, (int,long)), filesize
         offset, size = 0, None
         contentsize = filesize
+        req.setHeader("accept-ranges", "bytes")
+        if not self.filenode.is_mutable():
+            # TODO: look more closely at Request.setETag and how it interacts
+            # with a conditional "if-etag-equals" request, I think this may
+            # need to occur after the setResponseCode below
+            req.setETag(base32.b2a(self.filenode.get_storage_index()))
+            # TODO: for mutable files, use the roothash
         rangeheader = req.getHeader('range')
         if rangeheader:
             # adapted from nevow.static.File