blob: 74f57a72a9041762f9f50732d2ce890d889810c5 [file] [log] [blame]
def main(request, response):
service_worker_header = request.headers.get('service-worker')
if 'header' in request.GET and service_worker_header != 'script':
return 400, [('Content-Type', 'text/plain')], 'Bad Request'
if 'no-header' in request.GET and service_worker_header == 'script':
return 400, [('Content-Type', 'text/plain')], 'Bad Request'
# no-cache itself to ensure the user agent finds a new version for each
# update.
headers = [('Cache-Control', 'no-cache, must-revalidate'),
('Pragma', 'no-cache'),
('Content-Type', 'application/javascript')]
body = '/* This is a service worker script */\n'
if 'import' in request.GET:
body += "importScripts('%s');" % request.GET['import']
return 200, headers, body