curl -d似乎忽略了换行符

时间:2015-07-27 17:50:03

标签: curl

使用curl' -d选项以纯文本形式发送多行文件时,新行似乎被忽略:

$ cat test.txt
line 1
line 2

当我使用curl将文件作为POST请求的主体发送时,这些行被粘在一个(" body":" line 1line 2"):

$ curl -X POST -H 'Content-type: text/plain' -d @test.txt http://echo.httpkit.com
{
  "method": "POST",
  "uri": "/",
  "path": {
    "name": "/",
    "query": "",
    "params": {}
  },
  "headers": {
    "x-forwarded-for": "104.155.92.247",
    "host": "echo.httpkit.com",
    "user-agent": "curl/7.35.0",
    "accept": "*/*",
    "content-type": "text/plain",
    "content-length": "6"
  },
  "body": "foobar",
  "ip": "127.0.0.1",
  "powered-by": "http://httpkit.com",
  "docs": "http://httpkit.com/echo"
}

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我的错,找到了完全相同的问题。 How to send line break with curl?

需要使用DROP TABLE tmp;选项:

--data-binary
相关问题