From: Vsevolod Stakhov Date: Wed, 26 Jun 2013 17:03:40 +0000 (+0100) Subject: Save http date for lua. X-Git-Tag: 0.6.0~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a51086aa8de0c0a53f94cfb24f0e23a7bdc944ac;p=thirdparty%2Frspamd.git Save http date for lua. --- diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index 9df019af4d..f83c5f6f42 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -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);