0

我正在尝试使用 httpx 上传文件。这是我的脚本:

import httpx

headers = { 'action': 'upload' }
file = 'filename.zip'
auth = httpx.DigestAuth('user', 'password')

files = {'upload-file': open('files/' + file, 'rb')}
with httpx.Client() as client:      
    r = httpx.post('http://192.168.10.10/upload', files=files, auth=auth, headers=headers)

该文件为 70Mb,脚本在请求发送完整的 70MB 之前失败 httpcore.WriteError: [Errno 32] Broken pipe

如果我删除auth=authhttp 请求发送完整的 70MB 并且请求以 401 状态完成。

像这样的请求是成功的:

r = httpx.get('http://192.168.10.10/index.html', auth=auth)

为什么身份验证会以某种方式导致上传失败?

4

0 回答 0