character encoding - What's the difference between \r\n and \n -
in terminal seems no difference between two
echo -en 'first\r\nsecond'
, echo -en 'first\n\second'
but in code without \r doesn't work
echo -en 'get /test http/1.1\r\nhost: localhost\r\n\r\n' | nc localhost 9292
works, but
echo -en 'get /test http/1.1\r\nhost: localhost\n\n' | nc localhost 9292
doesn't
anyone can explain why is?
some applications can handle both \r\n (a.k.a. crlf, carriage return line feed) , \n (a.k.a. lf, line feed) equivalently newline sequences. terminal example.
the http/1.1 specification dictates http header lines end crlf. so, http server adheres specification (such 1 you're running on localhost:9292) not interpret lf valid http header line termination sequence.
Comments
Post a Comment