value = v;
/* Steal strings */
g_hash_table_iter_steal (&it);
- g_hash_table_insert (task->request_headers, key, value);
+ g_hash_table_replace (task->request_headers, key, value);
}
g_hash_table_unref (query_args);
hn_tok = rspamd_ftok_map (hn);
hv_tok = rspamd_ftok_map (hv);
- g_hash_table_insert (task->request_headers, hn_tok, hv_tok);
+ g_hash_table_replace (task->request_headers, hn_tok, hv_tok);
switch (*hn_tok->begin) {
case 'd':
{
GHashTable *res;
rspamd_fstring_t *key = NULL, *value = NULL;
- rspamd_ftok_t *key_tok, *value_tok;
+ rspamd_ftok_t *key_tok = NULL, *value_tok = NULL;
const gchar *p, *c, *end;
struct http_parser_url u;
enum {
if ((*p == '&' || p == end) && p > c) {
/* We have a single parameter without a value */
key = rspamd_fstring_new_init (c, p - c);
- key_tok = g_slice_alloc (sizeof (*key_tok));
- key_tok->begin = key->str;
+ key_tok = rspamd_ftok_map (key);
key_tok->len = rspamd_decode_url (key->str, key->str,
key->len);
+
value = rspamd_fstring_new_init ("", 0);
- value_tok = g_slice_alloc (sizeof (*value_tok));
- value_tok->begin = value->str;
- value_tok->len = value->len;
- g_hash_table_insert (res, key_tok, value_tok);
+ value_tok = rspamd_ftok_map (value);
+
+ g_hash_table_replace (res, key_tok, value_tok);
state = parse_ampersand;
}
else if (*p == '=' && p > c) {
/* We have something like key=value */
key = rspamd_fstring_new_init (c, p - c);
- key_tok = g_slice_alloc (sizeof (*key_tok));
- key_tok->begin = key->str;
+ key_tok = rspamd_ftok_map (key);
key_tok->len = rspamd_decode_url (key->str, key->str,
key->len);
+
state = parse_eqsign;
}
else {
g_assert (key != NULL);
if (p > c) {
value = rspamd_fstring_new_init (c, p - c);
- value_tok = g_slice_alloc (sizeof (*value_tok));
- value_tok->begin = value->str;
+ value_tok = rspamd_ftok_map (value);
value_tok->len = rspamd_decode_url (value->str,
value->str,
value->len);
}
else {
value = rspamd_fstring_new_init ("", 0);
- value_tok = g_slice_alloc (sizeof (*value_tok));
- value_tok->begin = value->str;
- value_tok->len = value->len;
+ value_tok = rspamd_ftok_map (value);
}
- g_hash_table_insert (res, key_tok, value_tok);
+ g_hash_table_replace (res, key_tok, value_tok);
key = value = NULL;
+ key_tok = value_tok = NULL;
state = parse_ampersand;
}
else {