def not_being_called(): cookies = get_cookies() expires = datetime.utcnow() - timedelta(seconds=60) for cookie in cookies.keys(): sys.stdout.write( 'Set-Cookie: {}=deleted; expires={} GMT; Max-Age=0; path=/\r\n'. format(cookie, expires.strftime('%a, %d-%b-%Y %H:%M:%S')))
#!/usr/bin/env python3 import json import os import sys file = __file__.split(':/cygwin')[-1] http_root = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(file))))) sys.path.insert(0, http_root) from resources.portabilityLayer import get_cookies cookies = get_cookies() sys.stdout.write('Content-Type: text/html\r\n\r\n') print('''<!DOCTYPE html> <html> <head> <script src="/js-test-resources/js-test.js"></script> <script src="../../resources/cookie-utilities.js"></script> <script>_setCachedCookiesJSON('{}')</script> </head> <body> <script> window.jsTestIsAsync = true; description("Tests that a SameSite Lax cookie for 127.0.0.1 is sent with a redirect from a page with the same origin."); async function checkResult()
def reset_cookies_for_current_origin(): expires = datetime.utcnow() - timedelta(seconds=86400) for cookie in get_cookies().keys(): sys.stdout.write('Set-Cookie: {}=deleted; expires={} GMT; Max-Age=0; path=/\r\n'.format(cookie, expires.strftime('%a, %d-%b-%Y %H:%M:%S')))
from resources.portabilityLayer import get_cookies request_method = os.environ.get('REQUEST_METHOD', '') query = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True) request = {} if request_method == 'POST': form = cgi.FieldStorage() for key in form.keys(): request.update({ key: form.getvalue(key) }) else: query = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True) for key in query.keys(): request.update({ key: query[key][0] }) request.update(get_cookies()) sys.stdout.write('Content-Type: text/html; charset=UTF-8\r\n\r\n') print('''<html> <head> <script> function runTest() { var r = document.getElementById('result'); var o = document.getElementById('output').firstChild; if (o.nodeValue == \'\u2122\u5341\') r.innerHTML = "SUCCESS: query param is converted to UTF-8"; else r.innerHTML = "FAILURE: query param is not converted to UTF-8. value=" +
value = re.sub(r'boundary=.*$', r'', value) header_name = prettify(name) beacon_file.write('{}: {}\n'.format(header_name, value)) post_data = ''.join(sys.stdin.readlines()) if len(post_data) == 0: post_data = urlencode(get_post_data()) if boundary is not None: post_data = decode_multipart(post_data, boundary) beacon_file.write('Length: {}\n'.format(len(post_data))) if 'application/' in content_type: post_data = b64encode(post_data.encode()).decode() beacon_file.write('Body: {}\n'.format(post_data.strip())) beacon_file.close() os.rename(beacon_filename + '.tmp', beacon_filename) if 'dontclearcookies' not in query.keys(): expires = datetime.utcnow() - timedelta(seconds=60) for name in get_cookies().keys(): sys.stdout.write( 'Set-Cookie: {}=deleted; expires={} GMT; Max-Age=0; path=/\r\n'. format(name, expires.strftime('%a, %d-%b-%Y %H:%M:%S'))) sys.stdout.write('Content-Type: text/html\r\n\r\n')