How to send line break with curl?

前端 未结 9 1039
深忆病人
深忆病人 2020-11-27 15:21

I\'ve tried the following to send a line break with curl, but \\n is not interpreted by curl.

curl -X PUT -d \"my message\\n\" http://localhost:         


        
9条回答
  •  青春惊慌失措
    2020-11-27 15:46

    Not an answer to your question, but I would work around it by creating a temporary file containing the message and line break, and give curl that file to work on:

    curl -X PUT -d @message.txt http://localhost:8000/hello
    

    From the manual:

    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.

提交回复
热议问题