rspamd_fprintf (stdout, "Emails: %s\n", emitted);
free (emitted);
}
+ else if (g_ascii_strcasecmp (ucl_object_key (cur), "error") == 0) {
+ rspamd_fprintf (stdout, "Scan error: %s\n", ucl_object_tostring (cur));
+ }
else if (cur->type == UCL_OBJECT) {
/* Parse metric */
rspamc_metric_output (cur);
}
ucl_object_unref (result);
}
+ else if (err != NULL) {
+ rspamd_fprintf (stdout, "%s\n", err->message);
+ }
rspamd_fprintf (stdout, "\n");
fflush (stdout);
if (argc == 1) {
start_argc = argc;
in = stdin;
+ cmd = check_rspamc_command ("symbols");
}
else if (argc == 2) {
/* One argument is whether command or filename */
struct worker_task *task = lua_check_task (L);
InternetAddressList *addrs;
- if (task) {
+ if (task && task->message != NULL) {
#ifndef GMIME24
addrs = internet_address_parse_string (g_mime_message_get_sender (task->message));
#else
rspamd_protocol_write_reply (struct worker_task *task)
{
struct rspamd_http_message *msg;
- const gchar *ctype = "text/plain";
+ const gchar *ctype = "application/json";
+ ucl_object_t *top = NULL;
msg = rspamd_http_new_message (HTTP_RESPONSE);
msg->date = time (NULL);
debug_task ("writing reply to client");
if (task->error_code != 0) {
msg->code = task->error_code;
- msg->body = g_string_new (task->last_error);
+ top = ucl_object_insert_key (top, ucl_object_fromstring (task->last_error), "error", 0, false);
+ msg->body = g_string_sized_new (256);
+ rspamd_ucl_emit_gstring (top, UCL_EMIT_JSON_COMPACT, msg->body);
+ ucl_object_unref (top);
}
else {
switch (task->cmd) {
case CMD_SYMBOLS:
case CMD_PROCESS:
case CMD_SKIP:
- ctype = "application/json";
write_check_reply (msg, task);
break;
case CMD_PING:
}
row->scan_time = task->scan_milliseconds;
- row->len = task->msg->len;
+ row->len = (task->msg == NULL ? 0 : task->msg->len);
row->completed = TRUE;
}
if (msg->body->len == 0) {
msg_err ("got zero length body, cannot continue");
+ task->last_error = "message's body is empty";
+ task->error_code = RSPAMD_LENGTH_ERROR;
+ task->state = WRITE_REPLY;
return 0;
}
if (task->cfg->pre_filters == NULL) {
r = process_filters (task);
if (r == -1) {
- task->last_error = "Filter processing error";
+ task->last_error = "filter processing error";
task->error_code = RSPAMD_FILTER_ERROR;
task->state = WRITE_REPLY;
return 0;
new_task->is_mime = TRUE;
new_task->pre_result.action = METRIC_ACTION_NOACTION;
+ new_task->message_id = new_task->queue_id = "undef";
+
return new_task;
}