#!/usr/bin/env python3 import cgi import os import sys import tempfile from datetime import datetime, timedelta # This test loads an uncacheable main resource and a cacheable image subresource. # We request this page as a GET, then reload this page with a POST. # On the post request, the image should be loaded from the cache and no HTTP # request should be sent. The image resource will return 404 if it receives # a second request, which will cause us to FAIL. # See https://bugs.webkit.org/show_bug.cgi?id=38690 file = __file__.split(':/cygwin')[-1] http_root = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(file)))) request_method = os.environ.get('REQUEST_METHOD', '') exp_time = datetime.utcnow() - timedelta(seconds=1) sys.stdout.write( 'Cache-Control: no-cache, no-store, must-revalidate, max-age=0\r\n' 'Pragma: no-cache\r\n' 'Expires: {} +0000\r\n' 'Content-Type: text/html\r\n\r\n'.format(exp_time.strftime('%a, %d %b %Y %H:%M:%S')) ) sys.stdout.write( '\n' '
\n' '\n' '\n' ) request = {} if request_method == 'POST': form = cgi.FieldStorage() for key in sorted(form.keys()): request[key] = form.getvalue(key) if request.get('submit', '') == 'finish': tmpFilePath = os.path.join(tempfile.gettempdir(), 'cache_post-with-cached-subresources_state') if os.path.exists(tmpFilePath): sys.stdout.write( '' ) sys.stdout.write('