]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Do not add User-Agent if it exists
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 18 Jul 2019 14:36:38 +0000 (15:36 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 18 Jul 2019 14:36:38 +0000 (15:36 +0100)
src/libutil/http_connection.c

index 9bf7456e7f461ed60f625807d00d40fc4154dfc4..d653758cf17475fc44545d2677dbda74534e3109 100644 (file)
@@ -1965,8 +1965,15 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn
        }
 
        if (priv->ctx->config.user_agent && conn->type == RSPAMD_HTTP_CLIENT) {
-               rspamd_http_message_add_header (msg, "User-Agent",
-                               priv->ctx->config.user_agent);
+               struct rspamd_http_header *found = NULL;
+
+               HASH_FIND (hh, msg->headers, "User-Agent",
+                               sizeof ("User-Agent") - 1, found);
+
+               if (!found) {
+                       rspamd_http_message_add_header (msg, "User-Agent",
+                                       priv->ctx->config.user_agent);
+               }
        }
 
        if (encrypted) {