summaryrefslogtreecommitdiffstats
path: root/src/libserver/worker_util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-10 16:38:29 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-10 16:38:29 +0100
commit5bbd698d9649a09e1992caef99b1482c62a5a54f (patch)
tree3c9032073c44c175b3009e99a30408c1693defe0 /src/libserver/worker_util.c
parentde6e99a081384da39d119e15375febf0028cea9d (diff)
downloadrspamd-5bbd698d9649a09e1992caef99b1482c62a5a54f.tar.gz
rspamd-5bbd698d9649a09e1992caef99b1482c62a5a54f.zip
[Rework] Finish rework for the rest of places that use HTTP
Diffstat (limited to 'src/libserver/worker_util.c')
-rw-r--r--src/libserver/worker_util.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index bf596a343..9924671cf 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -24,6 +24,7 @@
#include "rspamd_control.h"
#include "libutil/map.h"
#include "libutil/map_private.h"
+#include "libutil/http_private.h"
#ifdef WITH_GPERF_TOOLS
#include <gperftools/profiler.h>
@@ -352,6 +353,7 @@ rspamd_controller_send_error (struct rspamd_http_connection_entry *entry,
{
struct rspamd_http_message *msg;
va_list args;
+ rspamd_fstring_t *reply;
msg = rspamd_http_new_message (HTTP_RESPONSE);
@@ -362,8 +364,9 @@ rspamd_controller_send_error (struct rspamd_http_connection_entry *entry,
msg->date = time (NULL);
msg->code = code;
- msg->body = rspamd_fstring_new ();
- rspamd_printf_fstring (&msg->body, "{\"error\":\"%V\"}", msg->status);
+ reply = rspamd_fstring_sized_new (msg->status->len + 16);
+ rspamd_printf_fstring (&reply, "{\"error\":\"%V\"}", msg->status);
+ rspamd_http_message_set_body_from_fstring_steal (msg, reply);
rspamd_http_connection_reset (entry->conn);
rspamd_http_connection_write_message (entry->conn,
msg,
@@ -381,12 +384,14 @@ rspamd_controller_send_string (struct rspamd_http_connection_entry *entry,
const gchar *str)
{
struct rspamd_http_message *msg;
+ rspamd_fstring_t *reply;
msg = rspamd_http_new_message (HTTP_RESPONSE);
msg->date = time (NULL);
msg->code = 200;
msg->status = rspamd_fstring_new_init ("OK", 2);
- msg->body = rspamd_fstring_new_init (str, strlen (str));
+ reply = rspamd_fstring_new_init (str, strlen (str));
+ rspamd_http_message_set_body_from_fstring_steal (msg, reply);
rspamd_http_connection_reset (entry->conn);
rspamd_http_connection_write_message (entry->conn,
msg,
@@ -404,13 +409,15 @@ rspamd_controller_send_ucl (struct rspamd_http_connection_entry *entry,
ucl_object_t *obj)
{
struct rspamd_http_message *msg;
+ rspamd_fstring_t *reply;
msg = rspamd_http_new_message (HTTP_RESPONSE);
msg->date = time (NULL);
msg->code = 200;
msg->status = rspamd_fstring_new_init ("OK", 2);
- msg->body = rspamd_fstring_sized_new (BUFSIZ);
- rspamd_ucl_emit_fstring (obj, UCL_EMIT_JSON_COMPACT, &msg->body);
+ reply = rspamd_fstring_sized_new (BUFSIZ);
+ rspamd_ucl_emit_fstring (obj, UCL_EMIT_JSON_COMPACT, &reply);
+ rspamd_http_message_set_body_from_fstring_steal (msg, reply);
rspamd_http_connection_reset (entry->conn);
rspamd_http_connection_write_message (entry->conn,
msg,