POST请求头中
Accept-Encoding : gzip, deflate, br
响应
Content-Encoding : br
如果python当前运行环境没有安装 brotli 或 brotlicffi 库,将导致不能正确解压响应数据,导致乱码。
安装任意一个之后立刻解决,见下图

httpx源码中
try:
import brotlicffi as brotli
except ImportError: # pragma: no cover
try:
import brotli
except ImportError:
brotli = None
httpx文档的说明
The HTTPX project relies on these excellent libraries:
httpcore- The underlying transport implementation forhttpx.h11- HTTP/1.1 support.certifi- SSL certificates.idna- Internationalized domain name support.sniffio- Async library autodetection.
As well as these optional installs:
h2- HTTP/2 support. (Optional, withhttpx[http2])socksio- SOCKS proxy support. (Optional, withhttpx[socks])rich- Rich terminal support. (Optional, withhttpx[cli])click- Command line client support. (Optional, withhttpx[cli])brotliorbrotlicffi- Decoding for "brotli" compressed responses. (Optional, withhttpx[brotli])
brotli 或 brotlicffi 是一个可选项,并不是依赖,默认不会安装。