tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

record-click.py (905B)


      1 # This responds with a page reporting a click event to the origin provided in
      2 # the `eligible_origin` query param. The pages loads `num_views` copies of
      3 # record-view.py as images in a clickiness-eligible way; with them reporting
      4 # view events.
      5 def main(request, response):
      6    eligible_origin = request.GET.get(b"eligible_origin")
      7    num_views = int(request.GET.get(b"num_views"))
      8    response.status = (200, b"OK")
      9    response.headers.set(b"Content-Type", b"text/html")
     10    response.headers.set(
     11        b"Ad-Auction-Record-Event",
     12        b"type=\"click\", eligible-origins=(\"%s\")" % eligible_origin)
     13 
     14    result = b"<!DOCTYPE html>"
     15    img_template = b"<img src=\"record-view.py?i=%d&eligible_origin=%s\"" + \
     16                   b" attributionsrc>"
     17    for i in range(0, num_views):
     18      view = img_template % (i, eligible_origin)
     19      result = result + view
     20    return result.decode("utf-8")