summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/range/resources/partial-script.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/fetch/range/resources/partial-script.py
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/fetch/range/resources/partial-script.py')
-rw-r--r--testing/web-platform/tests/fetch/range/resources/partial-script.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fetch/range/resources/partial-script.py b/testing/web-platform/tests/fetch/range/resources/partial-script.py
new file mode 100644
index 0000000000..a9570ec355
--- /dev/null
+++ b/testing/web-platform/tests/fetch/range/resources/partial-script.py
@@ -0,0 +1,29 @@
+"""
+This generates a partial response containing valid JavaScript.
+"""
+
+def main(request, response):
+ require_range = request.GET.first(b'require-range', b'')
+ pretend_offset = int(request.GET.first(b'pretend-offset', b'0'))
+ range_header = request.headers.get(b'Range', b'')
+
+ if require_range and not range_header:
+ response.set_error(412, u"Range header required")
+ response.write()
+ return
+
+ response.headers.set(b"Content-Type", b"text/plain")
+ response.headers.set(b"Accept-Ranges", b"bytes")
+ response.headers.set(b"Cache-Control", b"no-cache")
+ response.status = 206
+
+ to_send = b'self.scriptExecuted = true;'
+ length = len(to_send)
+
+ content_range = b"bytes %d-%d/%d" % (
+ pretend_offset, pretend_offset + length - 1, pretend_offset + length)
+
+ response.headers.set(b"Content-Range", content_range)
+ response.headers.set(b"Content-Length", length)
+
+ response.content = to_send