]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Save http date for lua.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 26 Jun 2013 17:03:40 +0000 (18:03 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 26 Jun 2013 17:03:40 +0000 (18:03 +0100)
src/lua/lua_http.c

index 9df019af4d7827b12ba02249d1b1c18c4b036c54..f83c5f6f42eb419d6feeb9019310f9bb126b2535 100644 (file)
@@ -60,6 +60,7 @@ struct lua_http_ud {
        gint fd;
        rspamd_io_dispatcher_t *io_dispatcher;
        gint rep_len;
+       time_t date;
        GList *headers;
 };
 
@@ -152,6 +153,12 @@ lua_http_push_reply (f_str_t *in, struct lua_http_ud *ud)
        /* Reply */
        lua_pushlstring (ud->L, in->begin, in->len);
 
+       /* Date */
+       if (ud->date != (time_t)-1) {
+               num ++;
+               lua_pushnumber (ud->L, ud->date);
+       }
+
        if (lua_pcall (ud->L, num, 0, 0) != 0) {
                msg_info ("call to %s failed: %s", ud->callback ? ud->callback : "local function", lua_tostring (ud->L, -1));
        }
@@ -220,6 +227,11 @@ lua_http_parse_header_line (struct lua_http_ud *ud, f_str_t *in)
                ud->rep_len = strtoul (new->value, NULL, 10);
        }
 
+       /* Check date */
+       if (g_ascii_strcasecmp (new->name, "date") == 0) {
+               ud->date = parse_http_date (new->value, -1);
+       }
+
        /* Insert a header to the list */
        ud->headers = g_list_prepend (ud->headers, new);