diff options
author | Nguyễn Gia Phong <cnx@loang.net> | 2025-07-01 03:39:22 +0900 |
---|---|---|
committer | Nguyễn Gia Phong <cnx@loang.net> | 2025-07-01 03:39:22 +0900 |
commit | 7d4b6d742dd412befc3a5cbfdc7c1e125f80c568 (patch) | |
tree | e5059ecae90849119cb50180fb9b4e4cd976c9f3 /src | |
parent | eb568a7a09cc35dde7b0d2a0828523ec724cddae (diff) | |
download | scadere-7d4b6d742dd412befc3a5cbfdc7c1e125f80c568.tar.gz |
Omit Atom from Content-Type for browser compat 0.2.2
Diffstat (limited to 'src')
-rw-r--r-- | src/scadere/__init__.py | 2 | ||||
-rw-r--r-- | src/scadere/listen.py | 11 |
2 files changed, 10 insertions, 3 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,' |