in reply to Web and newlines, aka perl vs ^M

I will quote the HTTP spec: "HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all protocol elements except the entity-body".

This means the request line and headers should use CRLF. Clients are sloppy about this and servers are forgiving. But you should be careful about the end-of-line characters. And don't use "\r\n" which is interpreted differently on different platforms but "\015\012".

Also, the body should not have the line-endings changed. It should be treated like a binary block. One advantage is that you don't need to examine the media type and worry about images being corrupted.