Re: CFNetwork?
Re: CFNetwork?
- Subject: Re: CFNetwork?
- From: Andy <email@hidden>
- Date: Thu, 27 Dec 2001 22:21:04 -0500
email@hidden wrote:
>
The line terminator for message-header fields is the sequence CRLF.
>
However, we recommend that applications, when parsing such headers,
>
recognize a single LF as a line terminator and ignore the leading CR.
>
>
This rules out what I'm about to suggest, and I'm not familiar
>
with this use of HTTP, but . . .
>
>
IF this thing were interpreting EITHER \r or \n as a line end,
>
then it would see no headers at all since the \r\n after the
>
GET line would mean "end of headers". And I know you must have
>
a Host header for 1.1, at least, for a valid request.
>
Please be *very* careful when writing server side code which deals with
line endings. There's a long standing "bug" (actually a misfeature of
the JDK) relating to this. Its so common and well known to Mac Java
programmers, Apple even have a technote on it:
http://developer.apple.com/technotes/tn/tn1157.html
The ever insightful Greg Guerin describes the problem in more detail here:
http://www.amug.org/~glguerin/sw/lines/overview.html#background
Basically, you need to make sure the code which handles the whole CR,
LF, CRLF mess *does not* try to read ahead one byte when it seems a CR
character, otherwise you can deadlock clients. This behaviour is usually
seen in Java programs where the client is running on a Mac, but it
ultimately due to the poor design of Java's readLine() method as used on
the server side.
Have a read and make sure you don't repeat Sun's mistakes ;)
--
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside
I think we finally found the killer app for Flash: animated stick men