diff options
Diffstat (limited to 'test/wpt/tests/service-workers/service-worker/resources/multipart-image.py')
-rw-r--r-- | test/wpt/tests/service-workers/service-worker/resources/multipart-image.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/wpt/tests/service-workers/service-worker/resources/multipart-image.py b/test/wpt/tests/service-workers/service-worker/resources/multipart-image.py new file mode 100644 index 0000000..9a3c035 --- /dev/null +++ b/test/wpt/tests/service-workers/service-worker/resources/multipart-image.py @@ -0,0 +1,23 @@ +# A request handler that serves a multipart image. + +import os + + +BOUNDARY = b'cutHere' + + +def create_part(path): + with open(path, u'rb') as f: + return b'Content-Type: image/png\r\n\r\n' + f.read() + b'--%s' % BOUNDARY + + +def main(request, response): + content_type = b'multipart/x-mixed-replace; boundary=%s' % BOUNDARY + headers = [(b'Content-Type', content_type)] + if b'approvecors' in request.GET: + headers.append((b'Access-Control-Allow-Origin', b'*')) + + image_path = os.path.join(request.doc_root, u'images') + body = create_part(os.path.join(image_path, u'red.png')) + body = body + create_part(os.path.join(image_path, u'red-16x16.png')) + return headers, body |