diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-06-26 18:03:40 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-06-26 18:03:40 +0100 |
commit | a51086aa8de0c0a53f94cfb24f0e23a7bdc944ac (patch) | |
tree | b689a54a8190aa6d21192de5c28f3ab37fb91ea6 /src/lua/lua_http.c | |
parent | a0f4aea00904ebb17c23b172b8cd8981effde6e2 (diff) | |
download | rspamd-a51086aa8de0c0a53f94cfb24f0e23a7bdc944ac.tar.gz rspamd-a51086aa8de0c0a53f94cfb24f0e23a7bdc944ac.zip |
Save http date for lua.
Diffstat (limited to 'src/lua/lua_http.c')
-rw-r--r-- | src/lua/lua_http.c | 12 |
1 files changed, 12 insertions, 0 deletions
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); |