diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-10 16:38:29 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-10 16:38:29 +0100 |
commit | 5bbd698d9649a09e1992caef99b1482c62a5a54f (patch) | |
tree | 3c9032073c44c175b3009e99a30408c1693defe0 /src/rspamadm | |
parent | de6e99a081384da39d119e15375febf0028cea9d (diff) | |
download | rspamd-5bbd698d9649a09e1992caef99b1482c62a5a54f.tar.gz rspamd-5bbd698d9649a09e1992caef99b1482c62a5a54f.zip |
[Rework] Finish rework for the rest of places that use HTTP
Diffstat (limited to 'src/rspamadm')
-rw-r--r-- | src/rspamadm/control.c | 8 | ||||
-rw-r--r-- | src/rspamadm/lua_repl.c | 13 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/rspamadm/control.c b/src/rspamadm/control.c index de6e48346..52fec99c6 100644 --- a/src/rspamadm/control.c +++ b/src/rspamadm/control.c @@ -17,7 +17,8 @@ #include "rspamadm.h" #include "cryptobox.h" #include "printf.h" -#include "http.h" +#include "libutil/http.h" +#include "libutil/http_private.h" #include "addr.h" #include "unix-std.h" #include <event.h> @@ -100,11 +101,14 @@ rspamd_control_finish_handler (struct rspamd_http_connection *conn, struct ucl_parser *parser; ucl_object_t *obj; rspamd_fstring_t *out; + const gchar *body; + gsize body_len; struct rspamadm_control_cbdata *cbdata = conn->ud; + body = rspamd_http_message_get_body (msg, &body_len); parser = ucl_parser_new (0); - if (!ucl_parser_add_chunk (parser, msg->body->str, msg->body->len)) { + if (!body || !ucl_parser_add_chunk (parser, body, body_len)) { rspamd_fprintf (stderr, "cannot parse server's reply: %s\n", ucl_parser_get_error (parser)); ucl_parser_free (parser); diff --git a/src/rspamadm/lua_repl.c b/src/rspamadm/lua_repl.c index f96aa2890..a7c598be0 100644 --- a/src/rspamadm/lua_repl.c +++ b/src/rspamadm/lua_repl.c @@ -17,6 +17,8 @@ #include "config.h" #include "rspamadm.h" #include "cryptobox.h" +#include "libutil/http.h" +#include "libutil/http_private.h" #include "printf.h" #include "lua/lua_common.h" #include "message.h" @@ -533,11 +535,14 @@ rspamadm_lua_handle_exec (struct rspamd_http_connection_entry *conn_ent, struct rspamadm_lua_repl_context *ctx; struct rspamadm_lua_repl_session *session = conn_ent->ud; ucl_object_t *obj, *elt; + const gchar *body; + gsize body_len; ctx = session->ctx; L = ctx->L; + body = rspamd_http_message_get_body (msg, &body_len); - if (msg->body == NULL || msg->body->len == 0) { + if (body == NULL) { rspamd_controller_send_error (conn_ent, 400, "Empty lua script"); return 0; @@ -547,8 +552,8 @@ rspamadm_lua_handle_exec (struct rspamd_http_connection_entry *conn_ent, err_idx = lua_gettop (L); /* First try return + input */ - tb = g_string_sized_new (msg->body->len + sizeof ("return ")); - rspamd_printf_gstring (tb, "return %V", msg->body); + tb = g_string_sized_new (body_len + sizeof ("return ")); + rspamd_printf_gstring (tb, "return %*s", (gint)body_len, body); if (luaL_loadstring (L, tb->str) != 0) { /* Reset stack */ @@ -556,7 +561,7 @@ rspamadm_lua_handle_exec (struct rspamd_http_connection_entry *conn_ent, lua_pushcfunction (L, &rspamd_lua_traceback); err_idx = lua_gettop (L); /* Try with no return */ - if (luaL_loadbuffer (L, msg->body->str, msg->body->len, "http input") != 0) { + if (luaL_loadbuffer (L, body, body_len, "http input") != 0) { rspamd_controller_send_error (conn_ent, 400, "Invalid lua script"); return 0; |