summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prefetch/resources/prefetch.py
blob: 4a0a7a360209059937222e9eaebbd38f05c6240e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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")

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

  return n