Skip to content

Commit

Permalink
s3 output plugin: added new variable to enable or disable headers
Browse files Browse the repository at this point in the history
When uploading an object to an AWS S3 bucket, a Content-Encoding header is automatically added to the object. When this object is later downloaded, web browsers recognize this header and automatically decompress the file. This behavior can lead to misleading file types across different operating systems, potentially causing compatibility issues or unexpected file handling.
  • Loading branch information
SimonelDavid committed Jan 31, 2025
1 parent e2461d6 commit 0368bd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugins/out_s3/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int create_headers(struct flb_s3 *ctx, char *body_md5,
if (ctx->content_type != NULL) {
headers_len++;
}
if (ctx->compression == FLB_AWS_COMPRESS_GZIP) {
if (ctx->compression == FLB_AWS_COMPRESS_GZIP && ctx->enable_content_encoding_header) {
headers_len++;
}
if (ctx->canned_acl != NULL) {
Expand Down Expand Up @@ -171,7 +171,7 @@ int create_headers(struct flb_s3 *ctx, char *body_md5,
s3_headers[n].val_len = strlen(ctx->content_type);
n++;
}
if (ctx->compression == FLB_AWS_COMPRESS_GZIP) {
if (ctx->compression == FLB_AWS_COMPRESS_GZIP && ctx->enable_content_encoding_header) {
s3_headers[n] = content_encoding_header;
n++;
}
Expand Down Expand Up @@ -2376,6 +2376,11 @@ static struct flb_config_map config_map[] = {
"Defaults to no compression. "
"If 'gzip' is selected, the Content-Encoding HTTP Header will be set to 'gzip'."
},
{
FLB_CONFIG_MAP_BOOL, "enable_content_encoding_header", "true",
0, FLB_TRUE, offsetof(struct flb_s3, enable_content_encoding_header),
"Set to false to disable the Content-Encoding: gzip header."
},
{
FLB_CONFIG_MAP_STR, "content_type", NULL,
0, FLB_FALSE, 0,
Expand Down
1 change: 1 addition & 0 deletions plugins/out_s3/s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct flb_s3 {
int send_content_md5;
int static_file_path;
int compression;
int enable_content_encoding_header;
int port;
int insecure;
size_t store_dir_limit_size;
Expand Down

0 comments on commit 0368bd0

Please sign in to comment.