aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
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/client
parentde6e99a081384da39d119e15375febf0028cea9d (diff)
downloadrspamd-5bbd698d9649a09e1992caef99b1482c62a5a54f.tar.gz
rspamd-5bbd698d9649a09e1992caef99b1482c62a5a54f.zip
[Rework] Finish rework for the rest of places that use HTTP
Diffstat (limited to 'src/client')
-rw-r--r--src/client/rspamc.c23
-rw-r--r--src/client/rspamdclient.c12
2 files changed, 22 insertions, 13 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index 8f7f463bb..8001bb9cb 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -14,8 +14,9 @@
* limitations under the License.
*/
#include "config.h"
-#include "util.h"
-#include "http.h"
+#include "libutil/util.h"
+#include "libutil/http.h"
+#include "libutil/http_private.h"
#include "rspamdclient.h"
#include "utlist.h"
#include "unix-std.h"
@@ -950,12 +951,12 @@ rspamc_stat_output (FILE *out, ucl_object_t *obj)
static void
rspamc_output_headers (FILE *out, struct rspamd_http_message *msg)
{
- struct rspamd_http_header *h;
+ struct rspamd_http_header *h, *htmp;
- LL_FOREACH (msg->headers, h)
- {
+ HASH_ITER (hh, msg->headers, h, htmp) {
rspamd_fprintf (out, "%T: %T\n", h->name, h->value);
}
+
rspamd_fprintf (out, "\n");
}
@@ -1223,6 +1224,8 @@ rspamc_client_cb (struct rspamd_client_connection *conn,
struct rspamc_command *cmd;
FILE *out = stdout;
gdouble finish = rspamd_get_ticks (), diff;
+ const gchar *body;
+ gsize body_len;
cmd = cbdata->cmd;
diff = finish - cbdata->start;
@@ -1275,9 +1278,13 @@ rspamc_client_cb (struct rspamd_client_connection *conn,
else if (err != NULL) {
rspamd_fprintf (out, "%s\n", err->message);
- if (json && msg != NULL && msg->body != NULL) {
- /* We can also output the resulting json */
- rspamd_fprintf (out, "%V\n", msg->body);
+ if (json && msg != NULL) {
+ body = rspamd_http_message_get_body (msg, &body_len);
+
+ if (body) {
+ /* We can also output the resulting json */
+ rspamd_fprintf (out, "%*s\n", (gint)body_len, body);
+ }
}
}
}
diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c
index d386664dc..5932da38b 100644
--- a/src/client/rspamdclient.c
+++ b/src/client/rspamdclient.c
@@ -14,8 +14,9 @@
* limitations under the License.
*/
#include "rspamdclient.h"
-#include "util.h"
-#include "http.h"
+#include "libutil/util.h"
+#include "libutil/http.h"
+#include "libutil/http_private.h"
#include "unix-std.h"
#ifdef HAVE_FETCH_H
@@ -115,7 +116,7 @@ rspamd_client_finish_handler (struct rspamd_http_connection *conn,
return 0;
}
else {
- if (msg->body == NULL || msg->body_buf.len == 0 || msg->code != 200) {
+ if (rspamd_http_message_get_body (msg, NULL) == NULL || msg->code != 200) {
err = g_error_new (RCLIENT_ERROR, msg->code, "HTTP error: %d, %.*s",
msg->code,
(gint)msg->status->len, msg->status->str);
@@ -205,6 +206,7 @@ rspamd_client_command (struct rspamd_client_connection *conn,
gsize remain, old_len;
GList *cur;
GString *input = NULL;
+ rspamd_fstring_t *body;
req = g_slice_alloc0 (sizeof (struct rspamd_client_request));
req->conn = conn;
@@ -243,11 +245,11 @@ rspamd_client_command (struct rspamd_client_connection *conn,
return FALSE;
}
- req->msg->body = rspamd_fstring_new_init (input->str, input->len);
+ body = rspamd_fstring_new_init (input->str, input->len);
+ rspamd_http_message_set_body_from_fstring_steal (req->msg, body);
req->input = input;
}
else {
- req->msg->body = NULL;
req->input = NULL;
}