requests About headers message sorting


session.py

```python
def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
    """Determines appropriate setting for a given request, taking into account
    the explicit setting on that request, and the setting in the session. If a
    setting is a dictionary, they will be merged together using `dict_class`
    """

    if session_setting is None:
        return request_setting

    if request_setting is None:
        return session_setting

    # Bypass if not a dictionary (e.g. verify)
    if not (
            isinstance(session_setting, Mapping) and
            isinstance(request_setting, Mapping)
    ):
        return request_setting

    merged_setting = dict_class(to_key_val_list(session_setting))
    merged_setting.update(to_key_val_list(request_setting))

    # Remove keys that are set to None. Extract keys first to avoid altering
    # the dictionary during iteration.
    none_keys = [k for (k, v) in merged_setting.items() if v is None]
    for key in none_keys:
        del merged_setting[key]

    return merged_setting
```


## Expected Result

Host: www.example.com

Referer: http://httpbin.org/get

User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36

Accept-Encoding: gzip, deflate

Accept: */*

Connection: keep-alive
`

## Actual Result

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36

Accept-Encoding: gzip, deflate

Accept: */*

Host: www.example.com

Referer: http://httpbin.org/get

Connection: keep-alive

## Reproduction Steps

```python
    import requests

    headers = {
        'Host': 'www.example.com',
        'Referer': 'http://httpbin.org/get',
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36',
        'Accept-Encoding': 'gzip, deflate',
        'Accept': '/'
    }
    proxies = {
        'http': 'http://192.168.1.100:8888',
        'https': 'https://192.168.1.100:8888'
    }

```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": "2.4.2"
  },
  "idna": {
    "version": "2.8"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.7.1"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "101000af",
    "version": "18.0.0"
  },
  "requests": {
    "version": "2.22.0"
  },
  "system_ssl": {
    "version": "1010009f"
  },
  "urllib3": {
    "version": "1.24.1"
  },
  "using_pyopenssl": true
}

```

This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c).


@HC-miss most of us are aware of this "bug" use __OrderedDict__ from __collections__ on the headers attribute to get around it.

```python
    from collections import OrderedDict
    import requests
    
    headers = OrderedDict(
        (
            ('Host', 'www.example.com'),
            ('Referer', 'http://httpbin.org/get'),
            ('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'),
            ('Accept-Encoding', 'gzip, deflate'),
            ('Accept', '/')
        )
    }
    
    proxies = {
        'http': 'http://192.168.1.100:8888',
        'https': 'https://192.168.1.100:8888'
    }
    
    session = requests.session()
    session.headers = headers
```