(newkids, caps) = self._create_immutable_children()
d = self.POST2(self.public_url + "/foo/newdir?t=mkdir-immutable",
simplejson.dumps(newkids))
+ def _stash_immdir_uri(uri):
+ self._immdir_uri = uri
+ return uri
+ d.addCallback(_stash_immdir_uri)
d.addCallback(_check_etags)
# Check that etags work with immutable files
self.failUnlessEqual(int(code), http.NOT_MODIFIED))
return d
d.addCallback(_check_match)
+
+ def _no_etag(uri, t):
+ target = "/uri/%s?t=%s" % (uri, t)
+ d = self.GET(target, return_response=True, followRedirect=True)
+ d.addCallback(lambda (data, code, headers):
+ self.failIf("etag" in headers, target))
+ return d
+ def _yes_etag(uri, t):
+ target = "/uri/%s?t=%s" % (uri, t)
+ d = self.GET(target, return_response=True, followRedirect=True)
+ d.addCallback(lambda (data, code, headers):
+ self.failUnless("etag" in headers, target))
+ return d
+
+ d.addCallback(lambda ign: _yes_etag(self._bar_txt_uri, ""))
+ d.addCallback(lambda ign: _yes_etag(self._bar_txt_uri, "json"))
+ d.addCallback(lambda ign: _yes_etag(self._bar_txt_uri, "uri"))
+ d.addCallback(lambda ign: _yes_etag(self._bar_txt_uri, "readonly-uri"))
+ d.addCallback(lambda ign: _no_etag(self._bar_txt_uri, "info"))
+
+ d.addCallback(lambda ign: _yes_etag(self._immdir_uri, ""))
+ d.addCallback(lambda ign: _yes_etag(self._immdir_uri, "json"))
+ d.addCallback(lambda ign: _yes_etag(self._immdir_uri, "uri"))
+ d.addCallback(lambda ign: _yes_etag(self._immdir_uri, "readonly-uri"))
+ d.addCallback(lambda ign: _no_etag(self._immdir_uri, "info"))
+ d.addCallback(lambda ign: _no_etag(self._immdir_uri, "rename-form"))
+
return d
# TODO: version of this with a Unicode filename
# This is where all of the directory-related ?t=* code goes.
t = get_arg(req, "t", "").strip()
- if not self.node.is_mutable():
+ # t=info contains variable ophandles, t=rename-form contains the name
+ # of the child being renamed. Neither is allowed an ETag.
+ FIXED_OUTPUT_TYPES = ["", "json", "uri", "readonly-uri"]
+ if not self.node.is_mutable() and t in FIXED_OUTPUT_TYPES:
si = self.node.get_storage_index()
if si and req.setETag('DIR:%s-%s' % (base32.b2a(si), t or "")):
return ""
req = IRequest(ctx)
t = get_arg(req, "t", "").strip()
- if not self.node.is_mutable():
+ # t=info contains variable ophandles, so is not allowed an ETag.
+ FIXED_OUTPUT_TYPES = ["", "json", "uri", "readonly-uri"]
+ if not self.node.is_mutable() and t in FIXED_OUTPUT_TYPES:
# if the client already has the ETag then we can
# short-circuit the whole process.
si = self.node.get_storage_index()