summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prefetch/resources/prefetch.py
blob: 14ac4d1699ea0c52ac4b40f0a4a0f71c99147073 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from wptserve.handlers import json_handler

@json_handler
def main(request, response):
  uuid = request.GET[b"uuid"]
  prefetch = request.headers.get(
      "Sec-Purpose", b"").decode("utf-8").startswith("prefetch")
  response.headers.set("Cache-Control", "no-store")

  n = request.server.stash.take(uuid)
  if n is None:
    n = 0
  if prefetch:
    n += 1
    request.server.stash.put(uuid, n)

  return n