diff --git a/scripts/demo_attachments.py b/scripts/demo_attachments.py index 2d1902f..21f98c2 100644 --- a/scripts/demo_attachments.py +++ b/scripts/demo_attachments.py @@ -18,6 +18,7 @@ import sys import urllib.error import urllib.request import uuid +from email.message import Message from pathlib import Path ROOT = Path(__file__).resolve().parents[1] @@ -30,7 +31,7 @@ class Client: self.base = base.rstrip("/") def call(self, method: str, path: str, *, token: str | None = None, body=None, raw: bytes | None = None, - headers: dict | None = None) -> tuple[int, dict, bytes]: + headers: dict | None = None) -> tuple[int, Message, bytes]: h = dict(headers or {}) if token: h["Authorization"] = "Bearer " + token @@ -41,12 +42,12 @@ class Client: req = urllib.request.Request(self.base + path, data=data, method=method, headers=h) try: with urllib.request.urlopen(req, timeout=30) as r: - return r.status, dict(r.headers), r.read() + return r.status, r.headers, r.read() # case-insensitive HTTPMessage except urllib.error.HTTPError as e: - return e.code, dict(e.headers), e.read() + return e.code, e.headers, e.read() -def show(label: str, status: int, headers: dict, payload: bytes, *, binary: bool = False) -> None: +def show(label: str, status: int, headers: Message, payload: bytes, *, binary: bool = False) -> None: inst = headers.get("X-Instance-Id", "-") if binary: text = f"{len(payload)} bytes, Content-Type {headers.get('Content-Type')}"