Skip to content

Commit 4cec0b5

Browse files
authored
gh-129965: Add more missing MIME types (#132845)
1 parent c2eaeee commit 4cec0b5

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,22 @@ mimetypes
10011001

10021002
* :rfc:`2361`: Change type for ``.avi`` to ``video/vnd.avi``
10031003
and for ``.wav`` to ``audio/vnd.wave``
1004-
* :rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``))
1004+
* :rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``)
10051005
* :rfc:`5334`: Add Ogg media (``.oga``, ``.ogg`` and ``.ogx``)
1006+
* :rfc:`6713`: Add gzip ``application/gzip`` (``.gz``)
10061007
* :rfc:`9639`: Add FLAC ``audio/flac`` (``.flac``)
1008+
* Add 7z ``application/x-7z-compressed`` (``.7z``)
1009+
* Add Android Package ``application/vnd.android.package-archive`` (``.apk``)
1010+
when not strict
1011+
* Add deb ``application/x-debian-package`` (``.deb``)
1012+
* Add glTF binary ``model/gltf-binary`` (``.glb``)
1013+
* Add glTF JSON/ASCII ``model/gltf+json`` (``.gltf``)
1014+
* Add M4V ``video/x-m4v`` (``.m4v``)
1015+
* Add PHP ``application/x-httpd-php`` (``.php``)
1016+
* Add RAR ``application/vnd.rar`` (``.rar``)
1017+
* Add RPM ``application/x-rpm`` (``.rpm``)
1018+
* Add STL ``model/stl`` (``.stl``)
1019+
* Add Windows Media Video ``video/x-ms-wmv`` (``.wmv``)
10071020
* De facto: Add WebM ``audio/webm`` (``.weba``)
10081021
* `ECMA-376
10091022
<https://ecma-international.org/publications-and-standards/standards/ecma-376/>`__:

Lib/mimetypes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ def _default_mime_types():
478478
'.js' : 'text/javascript',
479479
'.mjs' : 'text/javascript',
480480
'.epub' : 'application/epub+zip',
481+
'.gz' : 'application/gzip',
481482
'.json' : 'application/json',
482483
'.webmanifest': 'application/manifest+json',
483484
'.doc' : 'application/msword',
@@ -517,10 +518,13 @@ def _default_mime_types():
517518
'.pptx' : 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
518519
'.xlsx' : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
519520
'.docx' : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
521+
'.rar' : 'application/vnd.rar',
520522
'.wasm' : 'application/wasm',
523+
'.7z' : 'application/x-7z-compressed',
521524
'.bcpio' : 'application/x-bcpio',
522525
'.cpio' : 'application/x-cpio',
523526
'.csh' : 'application/x-csh',
527+
'.deb' : 'application/x-debian-package',
524528
'.dvi' : 'application/x-dvi',
525529
'.gtar' : 'application/x-gtar',
526530
'.hdf' : 'application/x-hdf',
@@ -530,10 +534,12 @@ def _default_mime_types():
530534
'.cdf' : 'application/x-netcdf',
531535
'.nc' : 'application/x-netcdf',
532536
'.p12' : 'application/x-pkcs12',
537+
'.php' : 'application/x-httpd-php',
533538
'.pfx' : 'application/x-pkcs12',
534539
'.ram' : 'application/x-pn-realaudio',
535540
'.pyc' : 'application/x-python-code',
536541
'.pyo' : 'application/x-python-code',
542+
'.rpm' : 'application/x-rpm',
537543
'.sh' : 'application/x-sh',
538544
'.shar' : 'application/x-shar',
539545
'.swf' : 'application/x-shockwave-flash',
@@ -623,6 +629,9 @@ def _default_mime_types():
623629
'.mht' : 'message/rfc822',
624630
'.mhtml' : 'message/rfc822',
625631
'.nws' : 'message/rfc822',
632+
'.gltf' : 'model/gltf+json',
633+
'.glb' : 'model/gltf-binary',
634+
'.stl' : 'model/stl',
626635
'.css' : 'text/css',
627636
'.csv' : 'text/csv',
628637
'.html' : 'text/html',
@@ -661,6 +670,8 @@ def _default_mime_types():
661670
'.qt' : 'video/quicktime',
662671
'.webm' : 'video/webm',
663672
'.avi' : 'video/vnd.avi',
673+
'.m4v' : 'video/x-m4v',
674+
'.wmv' : 'video/x-ms-wmv',
664675
'.movie' : 'video/x-sgi-movie',
665676
}
666677

@@ -670,6 +681,7 @@ def _default_mime_types():
670681
# Please sort these too
671682
common_types = _common_types_default = {
672683
'.rtf' : 'application/rtf',
684+
'.apk' : 'application/vnd.android.package-archive',
673685
'.midi': 'audio/midi',
674686
'.mid' : 'audio/midi',
675687
'.jpg' : 'image/jpg',

Lib/test/test_mimetypes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from platform import win32_edition
88
from test import support
99
from test.support import os_helper
10-
from test.support.script_helper import run_python_until_end
1110

1211
try:
1312
import _winapi
@@ -227,6 +226,7 @@ def check_extensions():
227226
for mime_type, ext in (
228227
("application/epub+zip", ".epub"),
229228
("application/octet-stream", ".bin"),
229+
("application/gzip", ".gz"),
230230
("application/ogg", ".ogx"),
231231
("application/postscript", ".ps"),
232232
("application/vnd.apple.mpegurl", ".m3u"),
@@ -240,6 +240,11 @@ def check_extensions():
240240
("application/vnd.openxmlformats-officedocument.presentationml.presentation", ".pptx"),
241241
("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".xlsx"),
242242
("application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".docx"),
243+
("application/vnd.rar", ".rar"),
244+
("application/x-7z-compressed", ".7z"),
245+
("application/x-debian-package", ".deb"),
246+
("application/x-httpd-php", ".php"),
247+
("application/x-rpm", ".rpm"),
243248
("application/x-texinfo", ".texi"),
244249
("application/x-troff", ".roff"),
245250
("application/xml", ".xsl"),
@@ -268,6 +273,9 @@ def check_extensions():
268273
("image/webp", ".webp"),
269274
("image/wmf", ".wmf"),
270275
("message/rfc822", ".eml"),
276+
("model/gltf+json", ".gltf"),
277+
("model/gltf-binary", ".glb"),
278+
("model/stl", ".stl"),
271279
("text/html", ".html"),
272280
("text/plain", ".txt"),
273281
("text/rtf", ".rtf"),
@@ -278,6 +286,8 @@ def check_extensions():
278286
("video/ogg", ".ogv"),
279287
("video/quicktime", ".mov"),
280288
("video/vnd.avi", ".avi"),
289+
("video/x-m4v", ".m4v"),
290+
("video/x-ms-wmv", ".wmv"),
281291
):
282292
with self.subTest(mime_type=mime_type, ext=ext):
283293
self.assertEqual(mimetypes.guess_extension(mime_type), ext)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add MIME types for ``.7z``, ``.apk``, ``.deb``, ``.glb``, ``.gltf``,
2+
``.gz``, ``.m4v``, ``.php``, ``.rar``, ``.rpm``, ``.stl`` and ``.wmv``.
3+
Patch by Hugo van Kemenade.

0 commit comments

Comments
 (0)