Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[ Win ] 4 http/tests/security/contentSecurityPolicy/ tests are failing
https://bugs.webkit.org/show_bug.cgi?id=225071 <rdar://problem/77172923> Reviewed by Jonathan Bedard. * http/tests/resources/redirect.py: (add_cache_control): (addCacheControl): Deleted. Canonical link: https://commits.webkit.org/237132@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276731 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
e8997e2
commit 11c6e5b0c6de07638e236cc040d3760f6d64acfa
Showing
2 changed files
with
43 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
|
||
from urllib.parse import unquote | ||
|
||
|
||
def addCacheControl(allowCache=True): | ||
if allowCache: | ||
sys.stdout.write('Cache-Control: public, max-age=86400\r\n') | ||
def add_cache_control(allow_cache): | ||
if allow_cache is not None: | ||
sys.stdout.write('Cache-Control: public, max-age=86400\r\n\r\n') | ||
else: | ||
sys.stdout.write('Cache-Control: no-store\r\n') | ||
# Workaround for https://bugs.webkit.org/show_bug.cgi?id=77538 | ||
# Caching redirects results in flakiness in tests that dump loader delegates. | ||
sys.stdout.write('Cache-Control: no-store\r\n\r\n') | ||
|
||
sys.stdout.write('Content-Type: text/html\r\n') | ||
|
||
query = {} | ||
for part in os.environ.get('QUERY_STRING', '').split('&'): | ||
if not part: | ||
continue | ||
query[part.split('=')[0]] = '='.join(part.split('=')[1:]) | ||
for key_value in os.environ.get('QUERY_STRING', '').split('&'): | ||
arr = key_value.split('=') | ||
if len(arr) > 1: | ||
if query.get(arr[0], None) is not None and arr[1] not in query[arr[0]]: | ||
query[arr[0]].append(unquote('='.join(arr[1:]))) | ||
else: | ||
query[arr[0]] = [unquote('='.join(arr[1:]))] | ||
else: | ||
query[arr[0]] = [''] | ||
|
||
url = unquote(query.get('url', None)) | ||
allowCache = True if query.get('allowCache', None) is not None else False | ||
refresh = query.get('refresh', None) | ||
code = query.get('code', '302') | ||
|
||
if refresh: | ||
allow_cache = query.get('allowCache', [None])[0] | ||
code = int(query.get('code', [302])[0]) | ||
refresh = query.get('refresh', [None])[0] | ||
url = query.get('url', [''])[0] | ||
|
||
sys.stdout.write('Content-Type: text/html\r\n') | ||
|
||
if refresh is not None: | ||
sys.stdout.write( | ||
'status: 200\r\n' | ||
'Refresh: {}; url={}\r\n'.format(refresh, url) | ||
) | ||
addCacheControl(allowCache) | ||
sys.stdout.write('\r\n') | ||
|
||
add_cache_control(allow_cache) | ||
sys.exit(0) | ||
|
||
sys.stdout.write('status: {}\r\n'.format(code)) | ||
sys.stdout.write('Location: {}\r\n'.format(url)) | ||
addCacheControl(allowCache) | ||
sys.stdout.write('\r\n') | ||
sys.stdout.write( | ||
'status: {}\r\n' | ||
'Location: {}\r\n'.format(code, url) | ||
) | ||
|
||
add_cache_control(allow_cache) |