1
0
Fork 0
firefox/testing/web-platform/tests/client-hints/resources/2x3-svg-scaled-by-sec-ch-width.py
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

22 lines
733 B
Python

def main(request, response):
"""
Simple handler that responds with an SVG image with width `2 * sec-ch-width`
and height `3 * sec-ch-width`, or 1x1 if sec-ch-width is not present.
"""
width = 1
height = 1
if b"sec-ch-width" in request.headers:
sec_ch_width = request.headers.get(b"sec-ch-width").decode()
width = 2 * int(sec_ch_width)
height = 3 * int(sec_ch_width)
response.headers.set(b"Content-Type", b"image/svg+xml")
response.content = str.encode(f"""<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="{width}"
height="{height}">
<rect width="100%" height="100%" fill="green" />
</svg>""")