From a51086aa8de0c0a53f94cfb24f0e23a7bdc944ac Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 26 Jun 2013 18:03:40 +0100 Subject: [PATCH] Save http date for lua. --- src/lua/lua_http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index 9df019af4..f83c5f6f4 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); -- 2.39.5