httpie-cli/httpie
Mickaël Schoentgen 6bd6648545
Simplify get_content_type() (#1125)
We were using the potential `encoding` returned by `mimetypes.guess_type()`
to expand the `Content-Type` header.
According to the RFC-7231 [1] the `Content-Type` should contain a charset
and nothing more. But as stated in the `mimetypes.guess_type()` doc [2],
the `encoding` would be the name of the program used to encode (e.g. compress
or gzip) the payload. The `encoding` is suitable for use as a `Content-Encoding`
header. See [3] for potential `encoding`s, none is a IANA registered one [4], and
so a valid charset to be used by the `Content-Type` header.

[1] https://httpwg.org/specs/rfc7231.html#header.content-type
[2] https://docs.python.org/3/library/mimetypes.html#guess_type
[3] 938e84b4fa/Lib/mimetypes.py (L416-L422)
[4] https://www.iana.org/assignments/character-sets/character-sets.xhtml
2021-08-06 12:35:38 +02:00
..
cli Uniformize UTF-8 naming (#1115) 2021-08-05 20:58:43 +02:00
output Uniformize UTF-8 naming (#1115) 2021-08-05 20:58:43 +02:00
plugins Uniformize UTF-8 naming (#1115) 2021-08-05 20:58:43 +02:00
__init__.py Normalize the version (#1101) 2021-07-01 10:34:51 +02:00
__main__.py Remove an useless shebang form non-executable file (#1073) 2021-05-27 19:17:04 +02:00
client.py Use UTF8 constant in FORM_CONTENT_TYPE as well 2021-08-05 21:00:17 +02:00
compat.py Python 2.7 support removal WIP 2019-08-29 08:53:56 +02:00
config.py Uniformize UTF-8 naming (#1115) 2021-08-05 20:58:43 +02:00
constants.py Uniformize UTF-8 naming (#1115) 2021-08-05 20:58:43 +02:00
context.py Uniformize UTF-8 naming (#1115) 2021-08-05 20:58:43 +02:00
core.py Fix printing redirected prepared request in verbose mode (#1088) 2021-06-15 13:39:46 +02:00
downloads.py --download: Use time.monotonic() and rework code to prevent ZeroDivisionError specific handling (#1113) 2021-07-29 16:05:56 +02:00
models.py Uniformize UTF-8 naming (#1115) 2021-08-05 20:58:43 +02:00
sessions.py Uniformize UTF-8 naming (#1115) 2021-08-05 20:58:43 +02:00
ssl.py Request content type 2020-09-25 14:44:22 +02:00
status.py Cleanup 2019-12-02 00:58:10 +01:00
uploads.py Use relative imports (#1057) 2021-05-05 14:13:39 +02:00
utils.py Simplify get_content_type() (#1125) 2021-08-06 12:35:38 +02:00