When sending over a multi-line file as plain text using curl's -d
option, the new lines seem to be ignored:
$ cat test.txt
line 1
line 2
When I send the file as body of a POST request with curl, the lines are glued in one ("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"
}
What am I doing wrong?