summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webtransport/handlers/query.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/webtransport/handlers/query.py
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webtransport/handlers/query.py')
-rw-r--r--testing/web-platform/tests/webtransport/handlers/query.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webtransport/handlers/query.py b/testing/web-platform/tests/webtransport/handlers/query.py
new file mode 100644
index 0000000000..75d458255a
--- /dev/null
+++ b/testing/web-platform/tests/webtransport/handlers/query.py
@@ -0,0 +1,19 @@
+from typing import Optional
+from urllib.parse import urlsplit, parse_qsl
+import json
+
+
+def session_established(session):
+ path: Optional[bytes] = None
+ for key, value in session.request_headers:
+ if key == b':path':
+ path = value
+ assert path is not None
+ qs = dict(parse_qsl(urlsplit(path).query))
+ token = qs[b'token']
+ if token is None:
+ raise Exception('token is missing, path = {}'.format(path))
+
+ stream_id = session.create_unidirectional_stream()
+ data = json.dumps(session.stash.take(key=token) or {}).encode('utf-8')
+ session.send_stream_data(stream_id, data, end_stream=True)