aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-07-01 03:39:22 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-07-01 03:39:22 +0900
commit7d4b6d742dd412befc3a5cbfdc7c1e125f80c568 (patch)
treee5059ecae90849119cb50180fb9b4e4cd976c9f3 /src
parenteb568a7a09cc35dde7b0d2a0828523ec724cddae (diff)
downloadscadere-7d4b6d742dd412befc3a5cbfdc7c1e125f80c568.tar.gz
Omit Atom from Content-Type for browser compat0.2.2
Diffstat (limited to 'src')
-rw-r--r--src/scadere/__init__.py2
-rw-r--r--src/scadere/listen.py11
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,'