src/t_htp_req.c
static int
t_htp_req_parseHttpVersion( lua_State *L, const char **data, const char *end )
{
	const char *r = eat_lws( *data );  ///< runner char
	int         v = T_HTP_VER_ILL;
	size_t      l = end - r;

	if ((l > 10 && '\r'==*(r+8 )) || (l > 8 && '\n'==*(r+8)))
	{
		switch (*(r+7))
		{
			case '1': v = T_HTP_VER_11; break;
			case '0': v = T_HTP_VER_10; break;
			case '9': v = T_HTP_VER_09; break;
			default: luaL_error( L, "ILLEGAL HTTP version in message" ); break;
		}
		if (v < T_HTP_VER_11)
		{
			lua_pushboolean( L, 0 );
			lua_setfield( L, 1, "keepAlive" );
		}
		lua_pushinteger( L, v );
		lua_setfield( L, 1, "version" );
		// HTTP/1.1/r/n/r/n
		// HTTP/1.1/n/n      -- play nice with sloppy implementations
		// 01234567890
		lua_pushinteger( L, ((l>10 && '\r'==*(r+10)) || ('\n'==*(r+8) && '\n'==*(r+9)))
			? T_HTP_REQ_DONE
			: T_HTP_REQ_HEADERS );
		lua_setfield( L, 1, "state" );
		(*data) = r + 8;  // relocate to \r or\n after first line

		return 8;
	}
	return 0;
}
/**--------------------------------------------------------------------------
 * Parse HTTP Version from the request.
 * Stack: requesttable
 * \param  lua_State   L.
 * \param  char **data pointer within to data stream.
 * \param  char *end   end of data strem.
 * \return bool        0 means not enough data, 1 means done successfully
 * --------------------------------------------------------------------------*/
Parse HTTP Version from the request.
Stack: requesttable
\param  lua_State   L.
\param  char **data pointer within to data stream.
\param  char *end   end of data strem.
\return bool        0 means not enough data, 1 means done successfully
Parse HTTP Version from the request . Stack : requesttable \ param lua_State L . \ param char ** data pointer within to data stream . \ param char * end end of data strem . \ return bool 0 means not enough data 1 means done successfully
static int
t_htp_req_parseHttpVersion( lua_State *L, const char **data, const char *end )
{
	const char *r = eat_lws( *data );  
	int         v = T_HTP_VER_ILL;
	size_t      l = end - r;
	if ((l > 10 && '\r'==*(r+8 )) || (l > 8 && '\n'==*(r+8)))
	{
		switch (*(r+7))
		{
			case '1': v = T_HTP_VER_11; break;
			case '0': v = T_HTP_VER_10; break;
			case '9': v = T_HTP_VER_09; break;
			default: luaL_error( L, "ILLEGAL HTTP version in message" ); break;
		}
		if (v < T_HTP_VER_11)
		{
			lua_pushboolean( L, 0 );
			lua_setfield( L, 1, "keepAlive" );
		}
		lua_pushinteger( L, v );
		lua_setfield( L, 1, "version" );
		lua_pushinteger( L, ((l>10 && '\r'==*(r+10)) || ('\n'==*(r+8) && '\n'==*(r+9)))
			? T_HTP_REQ_DONE
			: T_HTP_REQ_HEADERS );
		lua_setfield( L, 1, "state" );
		(*data) = r + 8;  
		return 8;
	}
	return 0;
}
static int t_htp_req_parseHttpVersion ( lua_State * L , const char * * data , const char * end ) { const char * r = eat_lws ( * data ) ; int v = T_HTP_VER_ILL ; size_t l = end - r ; if ( ( l > 10 && ' \r ' == * ( r + 8 ) ) || ( l > 8 && ' \n ' == * ( r + 8 ) ) ) { switch ( * ( r + 7 ) ) { case ' ' : v = T_HTP_VER_11 ; break ; case ' ' : v = T_HTP_VER_10 ; break ; case ' ' : v = T_HTP_VER_09 ; break ; default : luaL_error ( L , " " ) ; break ; } if ( v < T_HTP_VER_11 ) { lua_pushboolean ( L , 0 ) ; lua_setfield ( L , 1 , " " ) ; } lua_pushinteger ( L , v ) ; lua_setfield ( L , 1 , " " ) ; lua_pushinteger ( L , ( ( l > 10 && ' \r ' == * ( r + 10 ) ) || ( ' \n ' == * ( r + 8 ) && ' \n ' == * ( r + 9 ) ) ) ? T_HTP_REQ_DONE : T_HTP_REQ_HEADERS ) ; lua_setfield ( L , 1 , " " ) ; ( * data ) = r + 8 ; return 8 ; } return 0 ; }
Parse HTTP Version from the request.
Parse HTTP Version from the request .
///< runner char // HTTP/1.1/r/n/r/n // HTTP/1.1/n/n      -- play nice with sloppy implementations // 01234567890 // relocate to \r or\n after first line