예제 #1
0
파일: uri.cpp 프로젝트: tempbottle/restbed
 multimap< string, string > Uri::get_query_parameters( void ) const
 {
     multimap< string, string > parameters;
     
     auto query = String::split( get_query( ), '&' );
     
     for ( auto parameter : query )
     {
         auto index = parameter.find_first_of( '=' );
         auto name = decode_parameter( parameter.substr( 0, index ) );
         auto value = decode_parameter( parameter.substr( index + 1, parameter.length( ) ) );
         
         parameters.insert( make_pair( name, value ) );
     }
     
     return parameters;
 }
예제 #2
0
static struct string_list *get_parameters(void)
{
	if (!query_params) {
		const char *query = getenv("QUERY_STRING");

		query_params = xcalloc(1, sizeof(*query_params));
		while (query && *query) {
			char *name = decode_parameter(&query, 1);
			char *value = decode_parameter(&query, 0);
			struct string_list_item *i;

			i = string_list_lookup(name, query_params);
			if (!i)
				i = string_list_insert(name, query_params);
			else
				free(i->util);
			i->util = value;
		}
	}
	return query_params;
}