src/__unused/t_htp_str.c
static int
lt_htp_str_writeHead( lua_State *L )
{
	struct t_htp_str *s = t_htp_str_check_ud( L, 1, 1 );
	int               i = lua_gettop( L );
	int               t = (LUA_TTABLE == lua_type( L, i )); // processing headers
	luaL_Buffer       lB;

	luaL_buffinit( L, &lB );
	// indicate the Content-Length was provided
	if (LUA_TNUMBER == lua_type( L, 3 ) || LUA_TNUMBER == lua_type( L, 4 ))
	{
		t_htp_str_formHeader( L, &lB, s,
			(int) luaL_checkinteger( L, 2 ),   // HTTP Status code
			(LUA_TSTRING == lua_type( L, 3))   // HTTP Status message
				? lua_tostring( L, 3 )
				: t_htp_status( luaL_checkinteger( L, 2 ) ),
			(LUA_TNUMBER == lua_type( L, 3))   // Content-Length
				?  (int) luaL_checkinteger( L, 3 )
				:  (int) luaL_checkinteger( L, 4 ),
			(t) ? i : 0                            // position of optional header table on stack
			);
	}
	else     // Prepare headers for chunked encoding
	{
		t_htp_str_formHeader( L, &lB, s,
			(int) luaL_checkinteger( L, 2 ),   // HTTP Status code
			(LUA_TSTRING == lua_type( L, 3))   // HTTP Status message
				? lua_tostring( L, 3 )
				: t_htp_status( luaL_checkinteger( L, 2 ) ),
			0,                                     // Content-Length 0 -> chunked
			(t) ? i : 0                            // position of optional header table on stack
			);
	}
	luaL_pushresult( &lB );
	s->state = T_HTP_STR_SEND;
	t_htp_str_addbuffer( L, s, lB.n, 0 );
	return 0;
}
/**-----------------------------------------------------------------------------
 * Set main values for HTTP response.
 * Takes different combinations of arguments.
 *     int                 - HTTP status code
 *     int,string          - HTTP status code, msg
 *     int,string,int      - HTTP status code, msg, length
 *     int,int             - HTTP status code, length
 * if there is a last argument being a table, it is treated as unordered key
 * value pair of header: value;
 * \param   L    The lua state.
 * \lparam  T.Http.Stream instance.
 * \lparam  int      HTTP status code.     // mandatory!
 * \lparam  int      length
 *           or
 * \lparam  string   HTTP message corresponding to HTTP status code.
 * \lparam  table    key:value pairs of HTTP headers.
 * \return  int    # of values pushed onto the stack.
 * ---------------------------------------------------------------------------*/
Set main values for HTTP response.
Takes different combinations of arguments.
int                 - HTTP status code
int,string          - HTTP status code, msg
int,string,int      - HTTP status code, msg, length
int,int             - HTTP status code, length
if there is a last argument being a table, it is treated as unordered key
value pair of header: value;
\param   L    The lua state.
Set main values for HTTP response . Takes different combinations of arguments . int - HTTP status code int string - HTTP status code msg int string int - HTTP status code msg length int int - HTTP status code length if there is a last argument being a table it is treated as unordered key value pair of header : value ; \ param L The lua state .
static int
lt_htp_str_writeHead( lua_State *L )
{
	struct t_htp_str *s = t_htp_str_check_ud( L, 1, 1 );
	int               i = lua_gettop( L );
	int               t = (LUA_TTABLE == lua_type( L, i )); 
	luaL_Buffer       lB;
	luaL_buffinit( L, &lB );
	if (LUA_TNUMBER == lua_type( L, 3 ) || LUA_TNUMBER == lua_type( L, 4 ))
	{
		t_htp_str_formHeader( L, &lB, s,
			(int) luaL_checkinteger( L, 2 ),   
			(LUA_TSTRING == lua_type( L, 3))   
				? lua_tostring( L, 3 )
				: t_htp_status( luaL_checkinteger( L, 2 ) ),
			(LUA_TNUMBER == lua_type( L, 3))   
				?  (int) luaL_checkinteger( L, 3 )
				:  (int) luaL_checkinteger( L, 4 ),
			(t) ? i : 0                            
			);
	}
	else     
	{
		t_htp_str_formHeader( L, &lB, s,
			(int) luaL_checkinteger( L, 2 ),   
			(LUA_TSTRING == lua_type( L, 3))   
				? lua_tostring( L, 3 )
				: t_htp_status( luaL_checkinteger( L, 2 ) ),
			0,                                      0 -> chunked
			(t) ? i : 0                            
			);
	}
	luaL_pushresult( &lB );
	s->state = T_HTP_STR_SEND;
	t_htp_str_addbuffer( L, s, lB.n, 0 );
	return 0;
}
static int lt_htp_str_writeHead ( lua_State * L ) { struct t_htp_str * s = t_htp_str_check_ud ( L , 1 , 1 ) ; int i = lua_gettop ( L ) ; int t = ( LUA_TTABLE == lua_type ( L , i ) ) ; luaL_Buffer lB ; luaL_buffinit ( L , & lB ) ; if ( LUA_TNUMBER == lua_type ( L , 3 ) || LUA_TNUMBER == lua_type ( L , 4 ) ) { t_htp_str_formHeader ( L , & lB , s , ( int ) luaL_checkinteger ( L , 2 ) , ( LUA_TSTRING == lua_type ( L , 3 ) ) ? lua_tostring ( L , 3 ) : t_htp_status ( luaL_checkinteger ( L , 2 ) ) , ( LUA_TNUMBER == lua_type ( L , 3 ) ) ? ( int ) luaL_checkinteger ( L , 3 ) : ( int ) luaL_checkinteger ( L , 4 ) , ( t ) ? i : 0 ) ; } else { t_htp_str_formHeader ( L , & lB , s , ( int ) luaL_checkinteger ( L , 2 ) , ( LUA_TSTRING == lua_type ( L , 3 ) ) ? lua_tostring ( L , 3 ) : t_htp_status ( luaL_checkinteger ( L , 2 ) ) , 0 , ( t ) ? i : 0 ) ; } luaL_pushresult ( & lB ) ; s -> state = T_HTP_STR_SEND ; t_htp_str_addbuffer ( L , s , lB . n , 0 ) ; return 0 ; }
Set main values for HTTP response.
Set main values for HTTP response .
// processing headers // indicate the Content-Length was provided // HTTP Status code // HTTP Status message // Content-Length // position of optional header table on stack // Prepare headers for chunked encoding // HTTP Status code // HTTP Status message // Content-Length 0 -> chunked // position of optional header table on stack