tor-browser

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

handler_utils.py (593B)


      1 import json
      2 
      3 def create_echo_response(request, response):
      4    response.headers.set(b"Access-Control-Allow-Origin", b"*")
      5    headers = {}
      6    for header in request.headers:
      7        key = header.decode('utf-8')
      8        value = request.headers.get(header).decode('utf-8')
      9        headers[key] = value
     10    result = json.dumps(headers)
     11    # If there is a callback, treat it as JSONP and wrap the result in the provided callback
     12    if b'callback' in request.GET:
     13        callback = request.GET.first(b"callback").decode('utf-8')
     14        result = callback + '(' + result + ');'
     15 
     16    return result