为什么请求会忽略我的自定义标头字段?

bus*_*ium 5 python python-requests

我有以下 Python 函数,它使用 requests 库发送 post 请求:

def http_post(self, url: str, headers: dict, data: str, auth: AuthBase):
        token = self._xsuaa.get_token(self._service)
        headers.update({'Proxy-Authorization': f"Bearer {token}"})
        res = requests.post(
            url,
            headers=headers,
            data=data,
            proxies={'http': self._proxy},
            auth=auth,
            verify=False,
            timeout=100,
            allow_redirects=True)
Run Code Online (Sandbox Code Playgroud)

打印headers字典时,它看起来像这样:

{
    'Content-Type': 'multipart/mixed;boundary=batch_4724f345-bb46-437d-a970-197a7b82bf41',
    'Content-Transfer-Encoding': 'binary',
    'sap-cancel-on-close': 'true',
    'sap-contextid-accept': 'header',
    'Accept': 'application/json',
    'Accept-Language': 'de-DE',
    'DataServiceVersion': '2.0',
    'MaxDataServiceVersion': '2.0',
    'Proxy-Authorization': 'Bearer <token>'
}
Run Code Online (Sandbox Code Playgroud)

然而,当我查看 时res.request.headers,我得到以下信息:

{
    'User-Agent': 'python-requests/2.26.0',
    'Accept-Encoding': 'gzip, deflate',
    'Accept': 'application/json',
    'Connection': 'keep-alive',
    'Content-Type': 'multipart/mixed; boundary=batch_4724f345-bb46-437d-a970-197a7b82bf41',
    'Content-Transfer-Encoding': 'binary',
    'sap-cancel-on-close': 'true',
    'sap-contextid-accept': 'header',
    'Accept-Language': 'de-DE',
    'DataServiceVersion': '2.0',
    'MaxDataServiceVersion': '2.0',
    'Content-Length': '659',
    'Authorization': 'Basic <auth>'
}
Run Code Online (Sandbox Code Playgroud)

由于某种原因,proxy-authorization标头字段消失了,因此,我在响应中收到 407 错误。我在文档中读到,URL 中提供的代理凭据会覆盖proxy-authorization标头,但我的 URL 不包含任何内容。我还尝试auth=auth从请求中删除该行,但问题仍然存在。有人能给我指出正确的方向,为什么这个字段似乎被请求忽略或覆盖?