]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Set host attribute properly when making HTTP request from lua
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 14 Jun 2016 08:20:42 +0000 (09:20 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 14 Jun 2016 08:20:42 +0000 (09:20 +0100)
src/lua/lua_http.c

index 298da5a47594e799ed30d024f7c5aa48af76e8fb..0c4eb976de25168157fb32f0431be2075f32127d 100644 (file)
@@ -65,6 +65,7 @@ struct lua_http_cbdata {
        struct timeval tv;
        rspamd_inet_addr_t *addr;
        gchar *mime_type;
+       gchar *host;
        gint fd;
        gint cbref;
 };
@@ -110,6 +111,10 @@ lua_http_fin (gpointer arg)
                g_free (cbd->mime_type);
        }
 
+       if (cbd->host) {
+               g_free (cbd->host);
+       }
+
        g_slice_free1 (sizeof (struct lua_http_cbdata), cbd);
 }
 
@@ -210,7 +215,8 @@ lua_http_make_connection (struct lua_http_cbdata *cbd)
                        NULL);
 
        rspamd_http_connection_write_message (cbd->conn, cbd->msg,
-                       NULL, cbd->mime_type, cbd, fd, &cbd->tv, cbd->ev_base);
+                       cbd->host, cbd->mime_type, cbd, fd,
+                       &cbd->tv, cbd->ev_base);
        /* Message is now owned by a connection object */
        cbd->msg = NULL;
 
@@ -451,6 +457,10 @@ lua_http_request (lua_State *L)
        msec_to_tv (timeout, &cbd->tv);
        cbd->fd = -1;
 
+       if (msg->host) {
+               cbd->host = rspamd_fstring_cstr (msg->host);
+       }
+
        if (session) {
                cbd->session = session;
                rspamd_session_add_event (session,