-
Newline character
In the literature I've been reading about HTTP, etc... I've become even more confused than I was before (though at least now I know about the problem) about how lines are terminated in HTTP messages (i.e. the character that represent the start of a new header, or a new section in the message). I know that different methods are used in differen't operating systems, but what is used in HTTP messages, and how is it represented in C?
-
In HTTP, a line is terminated by a carriage return followed by a newline character. In C, this is done by "\r\n". For instance, the first line in an HTTP request might look like:
"HTTP/1.1\r\n"
-
The line terminator in the headers is the crlf pair, represented in C as the string "\r\n".
Edit: bithub beat me to it - but just to be annoying, I'll point out that this "first line" is not valid ;)
-
For completeness then :)
"HTTP/1.1 200 OK\r\n"
-
-
Well since you're using HTTP 1.1, a Host header is required.
-
We were only posting first lines. There was no empty header line yet, so I could have posted the Host header later.