Skip to content

Commit

Permalink
aws: different user agent on windows vs linux
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Pettit <[email protected]>
  • Loading branch information
PettitWesley committed Nov 1, 2022
1 parent 27b9f6b commit d6d8c96
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/aws/flb_aws_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
#define AWS_ECS_METADATA_URI "ECS_CONTAINER_METADATA_URI_V4"
#define FLB_MAX_AWS_RESP_BUFFER_SIZE 0 /* 0 means unlimited capacity as per requirement */

#ifdef FLB_SYSTEM_WINDOWS
#define FLB_AWS_BASE_USER_AGENT "aws-fluent-bit-plugin-windows"
#define FLB_AWS_BASE_USER_AGENT_FORMAT "aws-fluent-bit-plugin-windows-%s"
#define FLB_AWS_BASE_USER_AGENT_LEN 29
#else
#define FLB_AWS_BASE_USER_AGENT "aws-fluent-bit-plugin"
#define FLB_AWS_BASE_USER_AGENT_FORMAT "aws-fluent-bit-plugin-%s"
#define FLB_AWS_BASE_USER_AGENT_LEN 21
#endif

struct flb_http_client *request_do(struct flb_aws_client *aws_client,
int method, const char *uri,
const char *body, size_t body_len,
Expand Down Expand Up @@ -369,16 +379,21 @@ struct flb_http_client *request_do(struct flb_aws_client *aws_client,
/* Add AWS Fluent Bit user agent header */
if (strcasecmp(aws_client->extra_user_agent, AWS_USER_AGENT_NONE) == 0) {
ret = flb_http_add_header(c, "User-Agent", 10,
"aws-fluent-bit-plugin", 21);
FLB_AWS_BASE_USER_AGENT, FLB_AWS_BASE_USER_AGENT_LEN);
}
else {
user_agent_prefix = flb_sds_create_size(64);
tmp = flb_sds_printf(&user_agent_prefix, "aws-fluent-bit-plugin-%s",
if (!user_agent_prefix) {
flb_errno();
flb_error("[aws_client] failed to create user agent");
goto error;
}
tmp = flb_sds_printf(&user_agent_prefix, FLB_AWS_BASE_USER_AGENT_FORMAT,
aws_client->extra_user_agent);
if (!tmp) {
flb_errno();
flb_sds_destroy(user_agent_prefix);
flb_error("[aws_client] failed to fetch user agent");
flb_error("[aws_client] failed to create user agent");
goto error;
}
user_agent_prefix = tmp;
Expand Down

0 comments on commit d6d8c96

Please sign in to comment.