Ejemplo n.º 1
0
void http::set_header( HEADERS& headers, const std::string& field_name, const std::string& field_value )
{
    HEADERS::iterator it = headers.begin(), it_end = headers.end();
    for ( ; it!=it_end; it++ )
    {
        HEADER& header = *it;
        if ( header.field_name == field_name )
        {
            if ( field_value.empty() )
            {
                headers.erase(it);
            }
            else
            {
                header.field_value = field_value;
            }
            return;
        }
    }

    HEADER new_header;
    new_header.field_name   = field_name;
    new_header.field_value  = field_value;
    headers.push_back( new_header );
}
Ejemplo n.º 2
0
void http::del_header( HEADERS& headers, const std::string& field_name )
{
    HEADERS::iterator it = headers.begin(), it_end = headers.end();
    for ( ; it!=it_end; it++ )
    {
        HEADER& header = *it;
        if ( header.field_name == field_name )
        {
            headers.erase(it);
            return;
        }
    }
}