From ecc4d67524827666aaa4931e17b3c19ad6d3cbe5 Mon Sep 17 00:00:00 2001 From: lecaros Date: Mon, 2 Sep 2024 14:49:21 -0400 Subject: [PATCH 1/3] upstream: remove call to flb_errno(). The error is displayed by flb_utils_proxy_url_split() Signed-off-by: lecaros --- src/flb_upstream.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/flb_upstream.c b/src/flb_upstream.c index c172245813c..b68a5d8c876 100644 --- a/src/flb_upstream.c +++ b/src/flb_upstream.c @@ -290,7 +290,6 @@ struct flb_upstream *flb_upstream_create(struct flb_config *config, &proxy_username, &proxy_password, &proxy_host, &proxy_port); if (ret == -1) { - flb_errno(); flb_free(u); return NULL; } From 5e8d089b36d092f703c492a600ec4a3e704469d4 Mon Sep 17 00:00:00 2001 From: lecaros Date: Mon, 2 Sep 2024 14:51:54 -0400 Subject: [PATCH 2/3] utils: improve error messaging inside the flb_utils_proxy_url_split() Signed-off-by: lecaros --- src/flb_utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/flb_utils.c b/src/flb_utils.c index 37e89d28a4f..588136ccc1e 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -1128,7 +1128,7 @@ int flb_utils_url_split(const char *in_url, char **out_protocol, /* * flb_utils_proxy_url_split parses a proxy's information from a http_proxy URL. - * The URL is in the form like `http://username:password@myproxy.com:8080`. + * The URL is in the form like `http://[username:password@]myproxy.com:8080`. * Note: currently only HTTP is supported. */ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, @@ -1147,9 +1147,11 @@ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, /* Parse protocol */ proto_sep = strstr(in_url, "://"); if (!proto_sep) { + flb_error("HTTP_PROXY variable must be set in the form of 'http://[username:password@]host:port'"); return -1; } if (proto_sep == in_url) { + flb_error("HTTP_PROXY variable must be set in the form of 'http://[username:password@]host:port'"); return -1; } @@ -1160,6 +1162,7 @@ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, } /* Only HTTP proxy is supported for now. */ if (strcmp(protocol, "http") != 0) { + flb_error("only HTTP proxy is supported."); flb_free(protocol); return -1; } From 70436308baf8fb487df83f2822363391f2c5838c Mon Sep 17 00:00:00 2001 From: lecaros Date: Mon, 2 Sep 2024 17:00:45 -0400 Subject: [PATCH 3/3] utils: fix typos Signed-off-by: lecaros --- src/flb_utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flb_utils.c b/src/flb_utils.c index 588136ccc1e..4a3ba02ad47 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -758,7 +758,7 @@ static inline void encoded_to_buf(char *out, const char *in, int len) /* * Write string pointed by 'str' to the destination buffer 'buf'. It's make sure - * to escape sepecial characters and convert utf-8 byte characters to string + * to escape special characters and convert utf-8 byte characters to string * representation. */ int flb_utils_write_str(char *buf, int *off, size_t size, @@ -1170,10 +1170,10 @@ int flb_utils_proxy_url_split(const char *in_url, char **out_protocol, /* Advance position after protocol */ proto_sep += 3; - /* Seperate `username:password` and `host:port` */ + /* Separate `username:password` and `host:port` */ at_sep = strrchr(proto_sep, '@'); if (at_sep) { - /* Parse username:passwrod part. */ + /* Parse username:password part. */ tmp = strchr(proto_sep, ':'); if (!tmp) { flb_free(protocol);