【发布时间】:2013-08-15 00:16:04
【问题描述】:
我正在玩 Python Requests 模块,到目前为止这很有趣。
但是,我在尝试使用 multipart/form-data 发布 zip 文件时遇到了问题。
我正在使用 Digest 身份验证,并且能够成功发布其他文件类型,例如.xls 等
我正在使用以下方式创建发布请求:
file = open('/Users/.../test.zip', 'rb').read()
r = requests.post(url, auth=HTTPDigestAuth('dev', 'dev'), data = {"mysubmit":"Go"}, files={"archive": ("test.zip", file)})
这会出错并给出:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.2.2.70', port=80): Max retries exceeded with url: /plugin_install
(Caused by <class 'socket.error'>: [Errno 32] Broken pipe)
我尝试过使用较小的 zip 文件并更改数据/文件值,但发生了同样的错误。
我是否遗漏了一些明显的东西?
感谢您提供的任何启发!
【问题讨论】:
-
你用
s = request.Session; s.auth...; s.post(...)试过了吗?
标签: python post python-requests