source/AccessorySDK/Support/HTTPUtils.c
Boolean	HTTPHeader_Validate( HTTPHeader *inHeader )
{
	const char *		src;
	const char *		end;
	
	require( inHeader->len < sizeof( inHeader->buf ), exit );
	src = inHeader->buf;
	end = src + inHeader->len;

	// Search for an empty line (HTTP-style header/body separator). CRLFCRLF, LFCRLF, or LFLF accepted.
	// $$$ TO DO: Start from the last search location to avoid re-searching the same data over and over.
	
	for( ;; )
	{
		while( ( src < end ) && ( src[ 0 ] != '\n' ) ) ++src;
		if( src >= end ) goto exit;
		++src;
		if( ( ( end - src ) >= 2 ) && ( src[ 0 ] == '\r' ) && ( src[ 1 ] == '\n' ) ) // CFLFCRLF or LFCRLF
		{
			src += 2;
			break;
		}
		else if( ( ( end - src ) >= 1 ) && ( src[ 0 ] == '\n' ) ) // LFLF
		{
			src += 1;
			break;
		}
	}
	inHeader->extraDataPtr	= src;
	inHeader->extraDataLen	= (size_t)( end - src );
	inHeader->len			= (size_t)( src - inHeader->buf );
	return( true );
	
exit:
	return( false );
}
//===========================================================================================================================
//	HTTPHeader_Validate
//
//	Parses for the end of an HTTP header and updates the HTTPHeader structure so it's ready to parse. Returns true if valid.
//	This assumes the "buf" and "len" fields are set. The other fields are set by this function.
//===========================================================================================================================
HTTPHeader_Validate
Parses for the end of an HTTP header and updates the HTTPHeader structure so it's ready to parse. Returns true if valid.
This assumes the "buf" and "len" fields are set. The other fields are set by this function.
HTTPHeader_Validate Parses for the end of an HTTP header and updates the HTTPHeader structure so it ' s ready to parse . Returns true if valid . This assumes the " buf " and " len " fields are set . The other fields are set by this function .
Boolean	HTTPHeader_Validate( HTTPHeader *inHeader )
{
	const char *		src;
	const char *		end;
	require( inHeader->len < sizeof( inHeader->buf ), exit );
	src = inHeader->buf;
	end = src + inHeader->len;
	for( ;; )
	{
		while( ( src < end ) && ( src[ 0 ] != '\n' ) ) ++src;
		if( src >= end ) goto exit;
		++src;
		if( ( ( end - src ) >= 2 ) && ( src[ 0 ] == '\r' ) && ( src[ 1 ] == '\n' ) ) 
		{
			src += 2;
			break;
		}
		else if( ( ( end - src ) >= 1 ) && ( src[ 0 ] == '\n' ) ) 
		{
			src += 1;
			break;
		}
	}
	inHeader->extraDataPtr	= src;
	inHeader->extraDataLen	= (size_t)( end - src );
	inHeader->len			= (size_t)( src - inHeader->buf );
	return( true );
exit:
	return( false );
}
Boolean HTTPHeader_Validate ( HTTPHeader * inHeader ) { const char * src ; const char * end ; require ( inHeader -> len < sizeof ( inHeader -> buf ) , exit ) ; src = inHeader -> buf ; end = src + inHeader -> len ; for ( ; ; ) { while ( ( src < end ) && ( src [ 0 ] != ' \n ' ) ) ++ src ; if ( src >= end ) goto exit ; ++ src ; if ( ( ( end - src ) >= 2 ) && ( src [ 0 ] == ' \r ' ) && ( src [ 1 ] == ' \n ' ) ) { src += 2 ; break ; } else if ( ( ( end - src ) >= 1 ) && ( src [ 0 ] == ' \n ' ) ) { src += 1 ; break ; } } inHeader -> extraDataPtr = src ; inHeader -> extraDataLen = ( size_t ) ( end - src ) ; inHeader -> len = ( size_t ) ( src - inHeader -> buf ) ; return ( true ) ; exit : return ( false ) ; }
HTTPHeader_Validate
Parses for the end of an HTTP header and updates the HTTPHeader structure so it's ready to parse.
HTTPHeader_Validate Parses for the end of an HTTP header and updates the HTTPHeader structure so it ' s ready to parse .
// Search for an empty line (HTTP-style header/body separator). CRLFCRLF, LFCRLF, or LFLF accepted. // $$$ TO DO: Start from the last search location to avoid re-searching the same data over and over. // CFLFCRLF or LFCRLF // LFLF