使用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"
}
我做错了什么?
答案 0 :(得分:0)