]> source.dussan.org Git - rspamd.git/commitdiff
Allow to find a header in message.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 28 Jan 2014 16:01:45 +0000 (16:01 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 28 Jan 2014 16:01:45 +0000 (16:01 +0000)
src/http.c
src/http.h

index 99bb2b8670c3011e874602f7a50c235cfb357d39..ccd44f2d89f23c3057fc4be0fc922a72bb0f0a97 100644 (file)
@@ -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
  */
index 929e5412617f9e85dac61f3f5dac4eaba6e2d56e..0c2c036f32f67db3b3817f579e80f5e88c2424e1 100644 (file)
@@ -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