summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/multipart-image.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/resources/multipart-image.py')
-rw-r--r--testing/web-platform/tests/service-workers/service-worker/resources/multipart-image.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/multipart-image.py b/testing/web-platform/tests/service-workers/service-worker/resources/multipart-image.py
new file mode 100644
index 0000000000..9a3c035f49
--- /dev/null
+++ b/testing/web-platform/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