linux - 作为输入发送到curl --data 和--data-encode 的文件需要写入的格式

标签 linux http post curl http-post

这有效:

curl -k -d 'VARTEST=vartest2&TEXTPARAM=text1%0Atext2&COMMENT=abc22' http://localhost:8080/job/TEST1/buildWithParameters?delay=0sec

curl -X POST -k 'http://localhost:8080/job/TEST1/buildWithParameters?delay=0sec&VARTEST=vartest2&TEXTPARAM=text1%0Atext2&COMMENT=abc22'

我希望能够将 -d 的参数写入文件并像这样运行命令行

curl -k -d @persargfile 'http://localhost:8080/job/TEST1/buildWithParameters?delay=0sec' -o abc.html

或者像这样

curl -k --data-urlencode @persargfile 'http://localhost:8080/job/TEST1/buildWithParameters?delay=0sec' -o abc.html

问题:

persargfile 的格式应该是什么?

最佳答案

作为man page状态,有多种可用格式:

  • ascii(--data-ascii)
  • urlencoded(--data-urlencoded)
  • 二进制(--data-binary)

您的应用程序似乎需要 ascii 选项。这意味着您的文件应包含:

VARTEST=vartest2&TEXTPARAM=text1%0Atext2&COMMENT=abc22

关于linux - 作为输入发送到curl --data 和--data-encode 的文件需要写入的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18836680/

相关文章:

linux - 用换行符替换空格,特殊字符包裹的空格除外

html - Linux服务器根文件夹

google-chrome - 浏览器从缓存中加载 JS 文件,但不加载 CSS 文件

laravel - React JS Fetch 返回空响应,但 Postman 不返回

正则表达式获取除当前词典和父词典之外的点文件

linux - assembly 上的清洁控制台

python - wget 给出响应 ERROR : 418 unused

java - 如何在 Android 上使用 cookie 发出 http 请求?

javascript - 标准 XMLHttpRequest 有效,但在 POST 到 REST 服务时 jQuery $.ajax 无效

javascript - 我的 ajax post 方法有效,但我无法通过 php 捕获该值