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/controller.c | |
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/controller.c')
-rw-r--r-- | src/controller.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/controller.c b/src/controller.c index f5efb4535..f2352e514 100644 --- a/src/controller.c +++ b/src/controller.c @@ -18,6 +18,7 @@ #include "libutil/rrd.h" #include "libutil/map.h" #include "libutil/map_private.h" +#include "libutil/http_private.h" #include "libstat/stat_api.h" #include "rspamd.h" #include "libserver/worker_util.h" @@ -871,7 +872,6 @@ rspamd_controller_handle_get_map (struct rspamd_http_connection_entry *conn_ent, gboolean found = FALSE; struct rspamd_http_message *reply; - if (!rspamd_controller_check_password (conn_ent, session, msg, FALSE)) { return 0; } @@ -919,10 +919,8 @@ rspamd_controller_handle_get_map (struct rspamd_http_connection_entry *conn_ent, reply = rspamd_http_new_message (HTTP_RESPONSE); reply->date = time (NULL); reply->code = 200; - reply->body = rspamd_fstring_sized_new (st.st_size); - /* Read the whole buffer */ - if (read (fd, reply->body->str, st.st_size) == -1) { + if (!rspamd_http_message_set_body_from_fd (reply, fd)) { close (fd); rspamd_http_message_free (reply); msg_err_session ("cannot read map %s: %s", bk->uri, strerror (errno)); @@ -930,8 +928,6 @@ rspamd_controller_handle_get_map (struct rspamd_http_connection_entry *conn_ent, return 0; } - reply->body->len = st.st_size; - close (fd); rspamd_http_connection_reset (conn_ent->conn); @@ -1420,7 +1416,7 @@ rspamd_controller_handle_learn_common ( return 0; } - if (msg->body == NULL || msg->body->len == 0) { + if (rspamd_http_message_get_body (msg, NULL) == NULL) { msg_err_session ("got zero length body, cannot continue"); rspamd_controller_send_error (conn_ent, 400, @@ -1521,7 +1517,7 @@ rspamd_controller_handle_scan (struct rspamd_http_connection_entry *conn_ent, return 0; } - if (msg->body == NULL || msg->body->len == 0) { + if (rspamd_http_message_get_body (msg, NULL) == NULL) { msg_err_session ("got zero length body, cannot continue"); rspamd_controller_send_error (conn_ent, 400, @@ -1595,7 +1591,7 @@ rspamd_controller_handle_saveactions ( return 0; } - if (msg->body == NULL || msg->body->len == 0) { + if (rspamd_http_message_get_body (msg, NULL) == NULL) { msg_err_session ("got zero length body, cannot continue"); rspamd_controller_send_error (conn_ent, 400, @@ -1714,7 +1710,7 @@ rspamd_controller_handle_savesymbols ( return 0; } - if (msg->body == NULL || msg->body->len == 0) { + if (rspamd_http_message_get_body (msg, NULL) == NULL) { msg_err_session ("got zero length body, cannot continue"); rspamd_controller_send_error (conn_ent, 400, @@ -1840,7 +1836,7 @@ rspamd_controller_handle_savemap (struct rspamd_http_connection_entry *conn_ent, return 0; } - if (msg->body == NULL || msg->body->len == 0) { + if (rspamd_http_message_get_body (msg, NULL) == NULL) { msg_err_session ("got zero length body, cannot continue"); rspamd_controller_send_error (conn_ent, 400, @@ -2162,7 +2158,7 @@ rspamd_controller_handle_custom (struct rspamd_http_connection_entry *conn_ent, cmd->privilleged)) { return 0; } - if (cmd->require_message && (msg->body == NULL || msg->body->len == 0)) { + if (cmd->require_message && (rspamd_http_message_get_body (msg, NULL) == NULL)) { msg_err_session ("got zero length body, cannot continue"); rspamd_controller_send_error (conn_ent, 400, |