Search code examples
rubynet-httpmultilinestring

Net::HTTP post with multiline param


I'd like to post a multiline param with Net::HTTP in Ruby. I tried adding \n or \r\n in the param string but it just arrives at destination as \n or \r\n.

Net::HTTP.post_form(URI.parse('http://mysite.com/post/uri'),{'param'=>'value','multiline_data'=>'data_line1\ndata_line2'})

How can I achieve that?


Solution

  • Line feeds in URL's are usually encoded as %0D%0A. You need to break your sentences using this to receive a multi line input on the other end.