关于curl:curl-d-data

57次阅读

共计 1106 个字符,预计需要花费 3 分钟才能阅读完成。

-d, –data <data>

  • POST 办法提交数据时,须应用 –data 来指定申请数据。和浏览器填充好表单点击 提交 按钮雷同。
  • 在没有指定内容类型的状况下,应用表单编码
  • 间接应用 –data 提交数据时,中文会乱码。

    curl –verbose -data “name=eliminate” –data “hobby=play 足球 football” localhost:8080/userAdd

  • –data 呈现屡次时,零碎会主动用符号 & 拼接起来。
  1. (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button.
  2. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F, –form.
  3. -d, –data is the same as –data-ascii. To post data purely binary, you should instead use the –data-binary option. To URL-encode the value of a form field you may use –data-urlencode.
  4. If any of these options is used more than once on the same command line, the data pieces specified will be merged together with a separating &-symbol. Thus, using ‘-d name=daniel -d skill=lousy’ would generate a post chunk that looks like ‘name=daniel&skill=lousy’.
  5. If you start the data with the letter @, the rest should be a file name to read the data from, or – if you want curl to read the data from stdin. The contents of the
    file must already be URL-encoded. Multiple files can also be specified. Posting data from a file named ‘foobar’ would thus be done with –data @foobar.
正文完
 0