Re: CFNetwork?
Re: CFNetwork?
- Subject: Re: CFNetwork?
- From: email@hidden
- Date: Thu, 27 Dec 2001 21:26:21 -0500
On Thursday, December 27, 2001, at 04:31 PM, Dustin Mierau wrote:
Well alrighty then. Yea I just looked at the rfc, you're right...
So this works:
CFHTTPMessageRef request;
NSString* requestString;
request = CFHTTPMessageCreateEmpty( kCFAllocatorDefault, TRUE );
requestString = [NSString stringWithString:@"GET / HTTP/1.1\nHost:
www.apple.com\nUser-Agent: Mozilla/4.0\n\n"];
CFHTTPMessageAppendBytes( request, [requestString cString],
[requestString cStringLength] );
if( CFHTTPMessageIsHeaderComplete( request ) )
NSLog( @"Header is complete" );
else
NSLog( @"Header is NOT complete" );
CFRelease( request );
Output is:
"Header is complete"
I tried it the other way, and sure enough, I get "Header is NOT
complete"..odd.
From 19.3 of rfc2068:
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.
Maybe you could put a \r\n after the Host and see if that is the
only header to get through?
Chris Hamlin