struct rspamd_http_message *msg)
{
gchar *headern, *err, *tmp;
- gboolean res = TRUE;
+ gboolean res = TRUE, validh;
struct rspamd_http_header *h;
LL_FOREACH (msg->headers, h)
{
headern = h->name->str;
+ validh = TRUE;
switch (headern[0]) {
case 'd':
}
else {
debug_task ("wrong header: %s", headern);
- res = FALSE;
+ validh = FALSE;
}
break;
case 'h':
}
else {
debug_task ("wrong header: %s", headern);
- res = FALSE;
+ validh = FALSE;
}
break;
case 'f':
}
else {
debug_task ("wrong header: %s", headern);
- res = FALSE;
+ validh = FALSE;
}
break;
case 'j':
}
else {
debug_task ("wrong header: %s", headern);
- res = FALSE;
+ validh = FALSE;
}
break;
case 'q':
}
else {
debug_task ("wrong header: %s", headern);
- res = FALSE;
+ validh = FALSE;
}
break;
case 'r':
}
else {
msg_info ("wrong header: %s", headern);
- res = FALSE;
+ validh = FALSE;
}
break;
case 'i':
}
else {
debug_task ("wrong header: %s", headern);
- res = FALSE;
+ validh = FALSE;
}
break;
case 'p':
}
}
else {
- res = FALSE;
+ validh = FALSE;
}
break;
case 's':
task->subject = h->value->str;
}
else {
- res = FALSE;
+ validh = FALSE;
}
break;
case 'u':
task->user = h->value->str;
}
else {
- res = FALSE;
+ validh = FALSE;
}
break;
case 'l':
}
}
else {
- res = FALSE;
+ validh = FALSE;
}
break;
default:
- debug_task ("wrong header: %s", headern);
- res = FALSE;
+ debug_task ("unknown header: %s", headern);
+ validh = FALSE;
break;
}
+
+ if (!validh) {
+ res = FALSE;
+ g_hash_table_replace (task->request_headers,
+ g_string_new_len(h->name->str, h->name->len),
+ g_string_new_len(h->value->str, h->value->len));
+ }
}
if (!res && task->cfg->strict_protocol_headers) {
}
}
+
+static void
+gstring_destruct (gpointer ptr)
+{
+ GString *s = (GString *)ptr;
+
+ g_string_free (s, TRUE);
+}
+
/*
* Create new task
*/
(rspamd_mempool_destruct_t) rcpt_destruct, new_task);
new_task->results = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
rspamd_mempool_add_destructor (new_task->task_pool,
- (rspamd_mempool_destruct_t) g_hash_table_destroy,
+ (rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->results);
new_task->re_cache = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
rspamd_mempool_add_destructor (new_task->task_pool,
- (rspamd_mempool_destruct_t) g_hash_table_destroy,
+ (rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->re_cache);
new_task->raw_headers = g_hash_table_new (rspamd_strcase_hash,
rspamd_strcase_equal);
+ new_task->request_headers = g_hash_table_new_full ((GHashFunc)g_string_hash,
+ (GEqualFunc)g_string_equal, gstring_destruct, gstring_destruct);
+ rspamd_mempool_add_destructor (new_task->task_pool,
+ (rspamd_mempool_destruct_t) g_hash_table_unref,
+ new_task->request_headers);
+ new_task->reply_headers = g_hash_table_new_full ((GHashFunc)g_string_hash,
+ (GEqualFunc)g_string_equal, gstring_destruct, gstring_destruct);
+ rspamd_mempool_add_destructor (new_task->task_pool,
+ (rspamd_mempool_destruct_t) g_hash_table_unref,
+ new_task->reply_headers);
rspamd_mempool_add_destructor (new_task->task_pool,
- (rspamd_mempool_destruct_t) g_hash_table_destroy,
+ (rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->raw_headers);
new_task->emails = g_tree_new (compare_email_func);
rspamd_mempool_add_destructor (new_task->task_pool,
gchar *user; /**< user to deliver */
gchar *subject; /**< subject (for non-mime) */
gchar *hostname; /**< hostname reported by MTA */
+ GHashTable *request_headers; /**< HTTP headers in a request */
+ GHashTable *reply_headers; /**< Custom reply headers */
GString *msg; /**< message buffer */
struct rspamd_http_connection *http_conn; /**< HTTP server connection */
struct rspamd_async_session * s; /**< async session object */