mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 18:06:46 +00:00
Short circuit GET on ETags match
When client does a conditional GET/HEAD with If-none-match:, if the condition fails (ie, the client's ETag matches the file's) then we can short-circuit the whole process and immediately return an empty body.
This commit is contained in:
parent
518ef25bdb
commit
4f1bc1b387
@ -415,12 +415,12 @@ class FileDownloader(rend.Page):
|
|||||||
contentsize = filesize
|
contentsize = filesize
|
||||||
req.setHeader("accept-ranges", "bytes")
|
req.setHeader("accept-ranges", "bytes")
|
||||||
if not self.filenode.is_mutable():
|
if not self.filenode.is_mutable():
|
||||||
# TODO: look more closely at Request.setETag and how it interacts
|
# if the client already has the ETag then we can short-circuit
|
||||||
# with a conditional "if-etag-equals" request, I think this may
|
# the whole process.
|
||||||
# need to occur after the setResponseCode below
|
|
||||||
si = self.filenode.get_storage_index()
|
si = self.filenode.get_storage_index()
|
||||||
if si:
|
if si and req.setETag(base32.b2a(si)):
|
||||||
req.setETag(base32.b2a(si))
|
return ""
|
||||||
|
|
||||||
# TODO: for mutable files, use the roothash. For LIT, hash the data.
|
# TODO: for mutable files, use the roothash. For LIT, hash the data.
|
||||||
# or maybe just use the URI for CHK and LIT.
|
# or maybe just use the URI for CHK and LIT.
|
||||||
rangeheader = req.getHeader('range')
|
rangeheader = req.getHeader('range')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user