Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | function handleRequest(request, response) |
michael@0 | 2 | { |
michael@0 | 3 | function etag(count) { |
michael@0 | 4 | return '"anetag' + count + '"'; |
michael@0 | 5 | } |
michael@0 | 6 | |
michael@0 | 7 | var count = parseInt(getState('count')); |
michael@0 | 8 | if (!count) |
michael@0 | 9 | count = 0; |
michael@0 | 10 | |
michael@0 | 11 | // reload(false) will make a request with If-None-Match headers |
michael@0 | 12 | var ifNoneMatch = request.hasHeader("If-None-Match") ? |
michael@0 | 13 | request.getHeader("If-None-Match") : ""; |
michael@0 | 14 | |
michael@0 | 15 | if (ifNoneMatch === etag(count)) { |
michael@0 | 16 | response.setStatusLine(request.httpVersion, "304", "Not Modified"); |
michael@0 | 17 | return; |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | count++; |
michael@0 | 21 | setState('count', count + ''); |
michael@0 | 22 | |
michael@0 | 23 | response.setHeader('Content-Type', 'text/html', false); |
michael@0 | 24 | response.setHeader('Cache-Control', 'public, max-age=3600', false); |
michael@0 | 25 | response.setHeader("ETag", etag(count), false); |
michael@0 | 26 | response.write('<html><body>' + count + '</body></html>'); |
michael@0 | 27 | } |