diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-28 16:01:45 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-28 16:01:45 +0000 |
commit | 26ede9ee72ced3e2b40123ab50bd0a518a8a6288 (patch) | |
tree | 89e0236b8b900fbcde404417d925dc716c04371b /src | |
parent | d5928fd6f07aaf64da5a8d2c837440da3d45da11 (diff) | |
download | rspamd-26ede9ee72ced3e2b40123ab50bd0a518a8a6288.tar.gz rspamd-26ede9ee72ced3e2b40123ab50bd0a518a8a6288.zip |
Allow to find a header in message.
Diffstat (limited to 'src')
-rw-r--r-- | src/http.c | 21 | ||||
-rw-r--r-- | src/http.h | 7 |
2 files changed, 28 insertions, 0 deletions
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 @@ -215,6 +215,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 */ |