Ticket #443: short-circuit-imm-etag.diff.txt

File short-circuit-imm-etag.diff.txt, 2.7 KB (added by jsgf, at 2010-03-12T00:33:12Z)

Short circuit GET when client already has ETag

Line 
1Thu Mar 11 16:18:11 PST 2010  Jeremy Fitzhardinge <jeremy@goop.org>
2  * Short circuit GET on ETags match
3 
4  When client does a conditional GET/HEAD with If-none-match:, if the
5  condition fails (ie, the client's ETag matches the file's) then we can
6  short-circuit the whole process and immediately return an empty body.
7
8New patches:
9
10[Short circuit GET on ETags match
11Jeremy Fitzhardinge <jeremy@goop.org>**20100312001811
12 Ignore-this: 79d8f088558390001d5ba6c9a2d17bb3
13 
14 When client does a conditional GET/HEAD with If-none-match:, if the
15 condition fails (ie, the client's ETag matches the file's) then we can
16 short-circuit the whole process and immediately return an empty body.
17] {
18hunk ./src/allmydata/web/filenode.py 363
19         contentsize = filesize
20         req.setHeader("accept-ranges", "bytes")
21         if not self.filenode.is_mutable():
22-            # TODO: look more closely at Request.setETag and how it interacts
23-            # with a conditional "if-etag-equals" request, I think this may
24-            # need to occur after the setResponseCode below
25+            # if the client already has the ETag then we can
26+            # short-circuit the whole process.
27             si = self.filenode.get_storage_index()
28hunk ./src/allmydata/web/filenode.py 366
29-            if si:
30-                req.setETag(base32.b2a(si))
31+            if si and req.setETag(base32.b2a(si)):
32+                return ""
33+
34         # TODO: for mutable files, use the roothash. For LIT, hash the data.
35         # or maybe just use the URI for CHK and LIT.
36         rangeheader = req.getHeader('range')
37}
38
39Context:
40
41[setup: add licensing declaration for setuptools (noticed by the FSF compliance folks)
42zooko@zooko.com**20100309184415
43 Ignore-this: 2dfa7d812d65fec7c72ddbf0de609ccb
44]
45[setup: fix error in licensing declaration from Shawn Willden, as noted by the FSF compliance division
46zooko@zooko.com**20100309163736
47 Ignore-this: c0623d27e469799d86cabf67921a13f8
48]
49[CREDITS to Jacob Appelbaum
50zooko@zooko.com**20100304015616
51 Ignore-this: 70db493abbc23968fcc8db93f386ea54
52]
53[desert-island-build-with-proper-versions
54jacob@appelbaum.net**20100304013858]
55[docs: a few small edits to try to guide newcomers through the docs
56zooko@zooko.com**20100303231902
57 Ignore-this: a6aab44f5bf5ad97ea73e6976bc4042d
58 These edits were suggested by my watching over Jake Appelbaum's shoulder as he completely ignored/skipped/missed install.html and also as he decided that debian.txt wouldn't help him with basic installation. Then I threw in a few docs edits that have been sitting around in my sandbox asking to be committed for months.
59]
60[TAG allmydata-tahoe-1.6.1
61david-sarah@jacaranda.org**20100228062314
62 Ignore-this: eb5f03ada8ea953ee7780e7fe068539
63]
64Patch bundle hash:
650d730c29b79e7708178bef2bb01a55fc29949a4d