aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/milter.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libserver/milter.c')
-rw-r--r--src/libserver/milter.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/libserver/milter.c b/src/libserver/milter.c
index 795c99bb0..a45f19c77 100644
--- a/src/libserver/milter.c
+++ b/src/libserver/milter.c
@@ -22,6 +22,9 @@
#include "unix-std.h"
#include "logger.h"
#include "ottery.h"
+#include "libutil/http.h"
+#include "libutil/http_private.h"
+#include "libserver/protocol_internal.h"
#include "utlist.h"
#define msg_err_milter(...) rspamd_default_log_function(G_LOG_LEVEL_CRITICAL, \
@@ -1081,3 +1084,46 @@ rspamd_milter_session_ref (struct rspamd_milter_session *session)
return session;
}
+
+struct rspamd_http_message *
+rspamd_milter_to_http (struct rspamd_milter_session *session)
+{
+ struct rspamd_http_message *msg;
+ guint i;
+ struct rspamd_email_address *rcpt;
+
+ g_assert (session != NULL);
+
+ msg = rspamd_http_new_message (HTTP_REQUEST);
+
+ msg->url = rspamd_fstring_assign (msg->url, "/" MSG_CMD_CHECK_V2,
+ sizeof ("/" MSG_CMD_CHECK_V2) - 1);
+
+ if (session->message) {
+ rspamd_http_message_set_body_from_fstring_steal (msg, session->message);
+ }
+
+ if (session->hostname && session->hostname->len > 0) {
+ rspamd_http_message_add_header_fstr (msg, HOSTNAME_HEADER,
+ session->hostname);
+ }
+
+ if (session->helo && session->helo->len > 0) {
+ rspamd_http_message_add_header_fstr (msg, HELO_HEADER,
+ session->helo);
+ }
+
+ if (session->from) {
+ rspamd_http_message_add_header_len (msg, FROM_HEADER,
+ session->from->raw, session->from->raw_len);
+ }
+
+ if (session->rcpts) {
+ PTR_ARRAY_FOREACH (session->rcpts, i, rcpt) {
+ rspamd_http_message_add_header_len (msg, RCPT_HEADER,
+ rcpt->raw, rcpt->raw_len);
+ }
+ }
+
+ return msg;
+} \ No newline at end of file