Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws: different user agent on windows vs linux #6325

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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