dom/browser-element/mochitest/file_bug741717.sjs

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 }

mercurial