diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-20 13:05:56 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-20 13:05:56 +0000 |
commit | cd2f92e40eca3ac7036e5cac9f90969a8d26655f (patch) | |
tree | 45048c70954fe8ca960252aecf082a3bdb828e59 /src/libutil/http_context.c | |
parent | 64604af61d3f1d8a7ada3eabe5fa62611620d16b (diff) | |
download | rspamd-cd2f92e40eca3ac7036e5cac9f90969a8d26655f.tar.gz rspamd-cd2f92e40eca3ac7036e5cac9f90969a8d26655f.zip |
[Feature] Support User-Agent in HTTP requests
Issue: #2750
Closes: #2750
Diffstat (limited to 'src/libutil/http_context.c')
-rw-r--r-- | src/libutil/http_context.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libutil/http_context.c b/src/libutil/http_context.c index 0237af1ab..39a02b179 100644 --- a/src/libutil/http_context.c +++ b/src/libutil/http_context.c @@ -50,11 +50,13 @@ rspamd_http_context_new_default (struct rspamd_config *cfg, static const int default_kp_size = 1024; static const gdouble default_rotate_time = 120; + static const gchar *default_user_agent = "rspamd-" RSPAMD_VERSION_FULL; ctx = g_malloc0 (sizeof (*ctx)); ctx->config.kp_cache_size_client = default_kp_size; ctx->config.kp_cache_size_server = default_kp_size; ctx->config.client_key_rotate_time = default_rotate_time; + ctx->config.user_agent = default_user_agent; if (cfg) { ctx->ssl_ctx = cfg->libs_ctx->ssl_ctx; @@ -127,6 +129,18 @@ rspamd_http_context_create (struct rspamd_config *cfg, if (rotate_time) { ctx->config.client_key_rotate_time = ucl_object_todouble (rotate_time); } + + const ucl_object_t *user_agent; + + user_agent = ucl_object_lookup (client_obj, "user_agent"); + + if (user_agent) { + ctx->config.user_agent = ucl_object_tostring (user_agent); + + if (ctx->config.user_agent && strlen (ctx->config.user_agent) == 0) { + ctx->config.user_agent = NULL; + } + } } server_obj = ucl_object_lookup (http_obj, "server"); |