aboutsummaryrefslogtreecommitdiffstats
path: root/src/rspamd_proxy.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-01 22:03:15 +0200
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-01 22:03:15 +0200
commita0fd450c98f17460842a1b73bed26a4f5672debf (patch)
treec785721696704d95dcf31a5621fd62cbd6a8a6fb /src/rspamd_proxy.c
parentb2e34f1884ed8c6c0346aaa007a1da70bad0a561 (diff)
downloadrspamd-a0fd450c98f17460842a1b73bed26a4f5672debf.tar.gz
rspamd-a0fd450c98f17460842a1b73bed26a4f5672debf.zip
[Feature] Add parsing scripts for master connection as well
Diffstat (limited to 'src/rspamd_proxy.c')
-rw-r--r--src/rspamd_proxy.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index 24c0fd4bf..43c1ec5ac 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -1040,6 +1040,16 @@ proxy_backend_master_finish_handler (struct rspamd_http_connection *conn,
session = bk_conn->s;
rspamd_http_connection_steal_msg (session->master_conn->backend_conn);
+
+ /* Reset spamc legacy */
+ if (msg->method >= HTTP_CHECK) {
+ msg->method = HTTP_GET;
+ }
+
+ if (msg->url->len == 0) {
+ msg->url = rspamd_fstring_append (msg->url, "/check", strlen ("/check"));
+ }
+
rspamd_http_message_remove_header (msg, "Content-Length");
rspamd_http_message_remove_header (msg, "Key");
rspamd_http_connection_reset (session->master_conn->backend_conn);
@@ -1048,7 +1058,7 @@ proxy_backend_master_finish_handler (struct rspamd_http_connection *conn,
&session->ctx->io_tv, session->ctx->ev_base);
if (!proxy_backend_parse_results (session, bk_conn, session->ctx->lua_state,
- -1, msg->body_buf.begin, msg->body_buf.len)) {
+ bk_conn->parser_from_ref, msg->body_buf.begin, msg->body_buf.len)) {
msg_warn_session ("cannot parse results from the master backend");
}
@@ -1129,6 +1139,15 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
rspamd_http_message_remove_header (msg, "Key");
rspamd_http_connection_reset (session->client_conn);
+ /* Reset spamc legacy */
+ if (msg->method >= HTTP_CHECK) {
+ msg->method = HTTP_GET;
+ }
+
+ if (msg->url->len == 0) {
+ msg->url = rspamd_fstring_append (msg->url, "/check", strlen ("/check"));
+ }
+
session->master_conn->backend_conn = rspamd_http_connection_new (
NULL,
proxy_backend_master_error_handler,
@@ -1136,6 +1155,8 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
RSPAMD_HTTP_CLIENT_SIMPLE,
RSPAMD_HTTP_CLIENT,
session->ctx->keys_cache);
+ session->master_conn->parser_from_ref = backend->parser_from_ref;
+ session->master_conn->parser_to_ref = backend->parser_to_ref;
rspamd_http_connection_set_key (session->master_conn->backend_conn,
session->ctx->local_key);