curl - 具有多部分/混合的 Ansible URI 模块?
问题描述
我正在尝试使用 Ansible URI 模块来复制下面的 curl 语句,但我的速度很快。是否支持多部分/混合,如果支持,如何。有什么想法吗?
curl "http://server_address" \
-X POST \
-H "Auth: blahblahblah" \
-H "Content-Type: multipart/mixed;" \
-F "request_payload=@pay_file.xml" \
-F "workbook=@file.twb"
解决方案
正如 cURL 文档所指出的,您的请求实际上似乎是矛盾的:
-F, --form <名称=内容>
(HTTP SMTP IMAP)对于 HTTP 协议族,这让 curl 模拟用户按下提交按钮的填写表单。这会导致 curl根据RFC 2388使用 Content-Type multipart/form-data发布数据。
来源:https ://curl.se/docs/manpage.html#-F ,强调我的
所以我猜你并没有真正以Content-Type: multipart/mixed
.
所以从这里看起来是你正在看的东西:
- uri:
url: http://example.org
## -X POST
method: POST
## -H "Auth: blahblahblah"
url_username: some_user
url_password: some_password
## You might also need this one
# force_basic_auth: true
## Content-type as forced by cURL when using -F
body_format: form-multipart
body:
## -F "request_payload=@pay_file.xml"
request_payload:
content: "{{ lookup('file', 'pay_file.xml') }}"
filename: pay_file.xml
mime_type: application/xml
## -F "workbook=@file.twb"
workbook:
content: "{{ lookup('file', 'file.twb') }}"
filename: file.twb
mime_type: application/twb
另见:
推荐阅读
- java - 在继续使用脚本之前等待选择下拉值 - Selenium WebDriver
- java - 如何在java中删除xml消息的soap信封
- java - 在我的视图中响应我的 getAdapter() 方法中的 IFindReplaceTarget
- notepad++ - 从一行中查找文件路径并使用记事本++插入下一行
- android - 工具栏中的进度条不占用整个宽度
- c# - 如何通过 ODBC 连接 Sage 200 数据库进行连接和查询?
- python - Python 2.7 返回值和添加函数
- otrs - 如何在 otrs 6 中创建示例模块 helloWorld
- javascript - 有没有办法将方法添加到众多对象的原型中
- apache-spark - 在 pyspark 数据框中旋转列和分组的有效方法