]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix order of initialization
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 9 Jun 2016 12:40:58 +0000 (13:40 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 9 Jun 2016 12:40:58 +0000 (13:40 +0100)
src/rspamd_proxy.c

index 844eaf1e81503f437adad1d434b9ac46b7c71611..7ca0cc51d70ee9356a042a34ade65fd3454c7516 100644 (file)
@@ -1122,6 +1122,17 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
                session->master_conn->name = "master";
                host = rspamd_http_message_find_header (msg, "Host");
 
+               /* Reset spamc legacy */
+               if (msg->method >= HTTP_SYMBOLS) {
+                       msg->method = HTTP_GET;
+                       session->is_spamc = TRUE;
+                       msg_info_session ("enabling legacy rspamc mode for session");
+               }
+
+               if (msg->url->len == 0) {
+                       msg->url = rspamd_fstring_append (msg->url, "/check", strlen ("/check"));
+               }
+
                if (host == NULL) {
                        backend = session->ctx->default_upstream;
                }
@@ -1134,22 +1145,6 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
                        }
                }
 
-               rspamd_http_connection_steal_msg (session->client_conn);
-               rspamd_http_message_remove_header (msg, "Content-Length");
-               rspamd_http_message_remove_header (msg, "Key");
-               rspamd_http_connection_reset (session->client_conn);
-
-               /* Reset spamc legacy */
-               if (msg->method >= HTTP_SYMBOLS) {
-                       msg->method = HTTP_GET;
-                       session->is_spamc = TRUE;
-                       msg_info_session ("enabling legacy rspamc mode for session");
-               }
-
-               if (msg->url->len == 0) {
-                       msg->url = rspamd_fstring_append (msg->url, "/check", strlen ("/check"));
-               }
-
                if (backend == NULL) {
                        /* No backend */
                        msg_err_session ("cannot find upstream for %s", host ? hostbuf : "default");
@@ -1200,6 +1195,11 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
                                msg, NULL, NULL, session->master_conn,
                                session->master_conn->backend_sock,
                                &session->ctx->io_tv, session->ctx->ev_base);
+                       rspamd_http_connection_steal_msg (session->client_conn);
+                       rspamd_http_message_remove_header (msg, "Content-Length");
+                       rspamd_http_message_remove_header (msg, "Key");
+                       rspamd_http_connection_reset (session->client_conn);
+
                }
        }
        else {
@@ -1211,6 +1211,10 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
        return 0;
 
 err:
+       rspamd_http_connection_steal_msg (session->client_conn);
+       rspamd_http_message_remove_header (msg, "Content-Length");
+       rspamd_http_message_remove_header (msg, "Key");
+       rspamd_http_connection_reset (session->client_conn);
        proxy_client_write_error (session, 404, "Backend not found");
 
        return 0;