summaryrefslogtreecommitdiffstats
path: root/src/rspamd_proxy.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-08 17:32:45 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-08 17:32:45 +0100
commit25bbf81895eecf72c7b89fe35d608f69968f91fc (patch)
tree764c40a5d5071293a03834bf56df24108187912c /src/rspamd_proxy.c
parentf28249c5855506a2e089fc79a429f59cef88b085 (diff)
downloadrspamd-25bbf81895eecf72c7b89fe35d608f69968f91fc.tar.gz
rspamd-25bbf81895eecf72c7b89fe35d608f69968f91fc.zip
[Minor] Add compression knobs to the proxy config
Diffstat (limited to 'src/rspamd_proxy.c')
-rw-r--r--src/rspamd_proxy.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index d485851bf..f579ec5c5 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -78,6 +78,7 @@ struct rspamd_http_upstream {
gint parser_to_ref;
gboolean local;
gboolean self_scan;
+ gboolean compress;
};
struct rspamd_http_mirror {
@@ -91,6 +92,7 @@ struct rspamd_http_mirror {
gint parser_from_ref;
gint parser_to_ref;
gboolean local;
+ gboolean compress;
};
static const guint64 rspamd_rspamd_proxy_magic = 0xcdeb4fd1fc351980ULL;
@@ -336,6 +338,11 @@ rspamd_proxy_parse_upstream (rspamd_mempool_t *pool,
ctx->has_self_scan = TRUE;
}
+ elt = ucl_object_lookup_any (obj, "compress", "compression", NULL);
+ if (elt && ucl_object_toboolean (elt)) {
+ up->compress = TRUE;
+ }
+
elt = ucl_object_lookup (obj, "hosts");
if (elt == NULL && !up->self_scan) {
@@ -484,6 +491,11 @@ rspamd_proxy_parse_mirror (rspamd_mempool_t *pool,
up->local = TRUE;
}
+ elt = ucl_object_lookup_any (obj, "compress", "compression", NULL);
+ if (elt && ucl_object_toboolean (elt)) {
+ up->compress = TRUE;
+ }
+
elt = ucl_object_lookup (obj, "timeout");
if (elt) {
ucl_object_todouble_safe (elt, &up->timeout);
@@ -1152,6 +1164,8 @@ proxy_backend_mirror_finish_handler (struct rspamd_http_connection *conn,
session = bk_conn->s;
+ proxy_request_decompress (msg);
+
if (!proxy_backend_parse_results (session, bk_conn, session->ctx->lua_state,
bk_conn->parser_from_ref, msg->body_buf.begin, msg->body_buf.len)) {
msg_warn_session ("cannot parse results from the mirror backend %s:%s",
@@ -1265,6 +1279,10 @@ proxy_open_mirror_connections (struct rspamd_proxy_session *session)
rspamd_http_message_set_body (msg, session->map, session->map_len);
}
+ if (m->compress) {
+ proxy_request_compress (msg);
+ }
+
rspamd_http_connection_write_message (bk_conn->backend_conn,
msg, NULL, NULL, bk_conn,
bk_conn->backend_sock,
@@ -1345,6 +1363,7 @@ proxy_backend_master_finish_handler (struct rspamd_http_connection *conn,
session = bk_conn->s;
rspamd_http_connection_steal_msg (session->master_conn->backend_conn);
+ proxy_request_decompress (msg);
rspamd_http_message_remove_header (msg, "Content-Length");
rspamd_http_message_remove_header (msg, "Key");
@@ -1639,6 +1658,10 @@ retry:
session->map, session->map_len);
}
+ if (backend->compress) {
+ proxy_request_compress (msg);
+ }
+
rspamd_http_connection_write_message (
session->master_conn->backend_conn,
msg, NULL, NULL, session->master_conn,