From 26ede9ee72ced3e2b40123ab50bd0a518a8a6288 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 28 Jan 2014 16:01:45 +0000 Subject: Allow to find a header in message. --- src/http.c | 21 +++++++++++++++++++++ src/http.h | 7 +++++++ 2 files changed, 28 insertions(+) (limited to 'src') diff --git a/src/http.c b/src/http.c index 99bb2b867..ccd44f2d8 100644 --- a/src/http.c +++ b/src/http.c @@ -873,6 +873,27 @@ void rspamd_http_message_add_header (struct rspamd_http_message *msg, } } +const gchar* +rspamd_http_message_find_header (struct rspamd_http_message *msg, const gchar *name) +{ + struct rspamd_http_header *hdr; + const gchar *res = NULL; + guint slen = strlen (name); + + if (msg != NULL) { + LL_FOREACH (msg->headers, hdr) { + if (hdr->name->len == slen) { + if (memcmp (hdr->name->str, name, slen) == 0) { + res = hdr->value->str; + break; + } + } + } + } + + return res; +} + /* * HTTP router functions */ diff --git a/src/http.h b/src/http.h index 929e54126..0c2c036f3 100644 --- a/src/http.h +++ b/src/http.h @@ -214,6 +214,13 @@ struct rspamd_http_message* rspamd_http_new_message (enum http_parser_type type) */ void rspamd_http_message_add_header (struct rspamd_http_message *rep, const gchar *name, const gchar *value); +/** + * Search for a specified header in message + * @param rep message + * @param name name of header + */ +const gchar* rspamd_http_message_find_header (struct rspamd_http_message *rep, const gchar *name); + /** * Free HTTP reply * @param rep -- cgit v1.2.3