static gboolean compact = FALSE;
static gboolean headers = FALSE;
static gboolean raw = FALSE;
+static gboolean ucl_reply = FALSE;
static gboolean extended_urls = FALSE;
static gboolean mime_output = FALSE;
static gboolean empty_input = FALSE;
{ "compact", '\0', 0, G_OPTION_ARG_NONE, &compact, "Output compact json reply", NULL},
{ "headers", 0, 0, G_OPTION_ARG_NONE, &headers, "Output HTTP headers",
NULL },
- { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "Output raw reply from rspamd",
+ { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "Input is a raw file, not an email file",
NULL },
- { "ucl", 0, 0, G_OPTION_ARG_NONE, &raw, "Output ucl reply from rspamd",
+ { "ucl", 0, 0, G_OPTION_ARG_NONE, &ucl_reply, "Output ucl reply from rspamd",
NULL },
{ "max-requests", 'n', 0, G_OPTION_ARG_INT, &max_requests,
"Maximum count of parallel requests to rspamd", NULL },
}
if (json || compact) {
- raw = TRUE;
+ ucl_reply = TRUE;
}
/* Argc and argv are shifted after this function */
g_option_context_free (context);
ADD_CLIENT_FLAG (flagbuf, "pass_all");
}
+ if (raw) {
+ ADD_CLIENT_HEADER (opts, "Raw", "yes");
+ }
+
if (classifier) {
ADD_CLIENT_HEADER (opts, "Classifier", classifier);
}
}
}
- if (json || raw || compact) {
+ if (json || ucl_reply || compact) {
/* We also append json data as a specific header */
if (json) {
json_header = ucl_object_emit (result,
rspamc_mime_output (out, result, input, time, err);
}
else if (result) {
- if (raw || cmd->command_output_func == NULL) {
+ if (ucl_reply || cmd->command_output_func == NULL) {
if (json) {
ucl_out = ucl_object_emit (result,
compact ? UCL_EMIT_JSON_COMPACT : UCL_EMIT_JSON);
if (headers && msg != NULL) {
rspamc_output_headers (out, msg);
}
- if (raw || cmd->command_output_func == NULL) {
+ if (ucl_reply || cmd->command_output_func == NULL) {
if (cmd->need_input) {
ucl_object_insert_key (result,
ucl_object_fromstring (cbdata->filename),
rspamd_fprintf (out, "%s\n", err->message);
if (json && msg != NULL) {
- const gchar *raw;
+ const gchar *raw_body;
gsize rawlen;
- raw = rspamd_http_message_get_body (msg, &rawlen);
+ raw_body = rspamd_http_message_get_body (msg, &rawlen);
- if (raw) {
+ if (raw_body) {
/* We can also output the resulting json */
rspamd_fprintf (out, "%*s\n", (gint)(rawlen - bodylen),
- raw);
+ raw_body);
}
}
}