diff options
-rw-r--r-- | src/scadere/__init__.py | 2 | ||||
-rw-r--r-- | src/scadere/listen.py | 11 | ||||
-rw-r--r-- | tst/test_listen.py | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/scadere/__init__.py b/src/scadere/__init__.py index 22aa273..baf79cf 100644 --- a/src/scadere/__init__.py +++ b/src/scadere/__init__.py @@ -8,7 +8,7 @@ from importlib.resources import files __all__ = ['__version__', 'GNUHelpFormatter', 'NetLoc', 'atom2xhtml', 'format_epilog', 'format_version'] -__version__ = '0.2.1' +__version__ = '0.2.2' EXAMPLE_PREFIX = ' ' * 2 # help2man's implementation detail diff --git a/src/scadere/listen.py b/src/scadere/listen.py index a435bdc..3cb6bb7 100644 --- a/src/scadere/listen.py +++ b/src/scadere/listen.py @@ -227,7 +227,7 @@ def set_http_time_locale(): setlocale(LC_TIME, 'C') -def write_xml(writer, http_version, application, func, *args, mtime=None): +def write_xml(writer, http_version, subtype, func, *args, mtime=None): """Write given document as XML.""" try: content = func(*args) @@ -236,7 +236,14 @@ def write_xml(writer, http_version, application, func, *args, mtime=None): raise else: write_status(writer, http_version, HTTPStatus.OK) - write_content_type(writer, f'application/{application}+xml') + if subtype == 'atom': + # Firefox would try to download an application/atom+xml + # and Chromium would display its source code + # instead of applying the XSLT stylesheet + # and rendering the resulting hypertext. + write_content_type(writer, 'application/xml') + else: + write_content_type(writer, f'application/{subtype}+xml') writer.write(f'Content-Length: {len(content)}\r\n'.encode()) if mtime is None: writer.write(b'Cache-Control: public,' diff --git a/tst/test_listen.py b/tst/test_listen.py index f0557d4..85c13f9 100644 --- a/tst/test_listen.py +++ b/tst/test_listen.py @@ -197,7 +197,7 @@ def equal_xml(a, b): async def check_feed(socket, base_url): """Check the Atom feed, its stylesheet, and entry pages.""" - feed = await fetch_xml(socket, base_url, 'application/atom+xml') + feed = await fetch_xml(socket, base_url, 'application/xml') await check_atom2xhtml(socket, f'{base_url}{__version__}.xslt') for entry in feed.findall('entry', ATOM_NAMESPACES): link = entry.find('link', ATOM_NAMESPACES).attrib |