tor-browser

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

script-with-cookie-header.py (979B)


      1 def main(request, response):
      2  script = request.GET.first(b"script")
      3 
      4  # Some, but not all, urls will send a query parameter indicating their
      5  # script will want to postMessage the parent to ack that it has loaded.
      6  should_ack_load = b"false"
      7  try:
      8    # The call to request.GET.first will fail if the parameter isn't present,
      9    # that's ok.
     10    if request.GET.first(b"should_ack_load") == b"true":
     11      should_ack_load = b"true"
     12  except:
     13    pass
     14  cookie_header = request.headers.get(b"Cookie", b"")
     15 
     16  body = b"""
     17  <!DOCTYPE html>
     18  <meta charset="utf-8">
     19  <title>Subframe with HTTP Cookies</title>
     20  <script src="/resources/testharness.js"></script>
     21  <script src="/resources/testdriver.js"></script>
     22  <script src="/resources/testdriver-vendor.js"></script>
     23  <script>
     24    var httpCookies = "%s";
     25    var should_ack_load = %s;
     26  </script>
     27 
     28  <body>
     29  <script src="%s"></script>
     30  </body>
     31 
     32  """ % (cookie_header, should_ack_load, script)
     33 
     34  return (200, [], body)