With requests python library it is possible to use OrderedDict to send headers in a specified order. I tried the same with HTTPX. with httpx.Client() as client: ordered_headers = ...
Method 1: unique-values, solution based on dict comprehension Method 2: non-unique values Method 3: type and order preserved I ran some tests, and method 1 is the one that provides the best average ...