Skip to content

Commit 45d3aa3

Browse files
committed
out_http: fix logic to handle status of compressed payloads (fix #10016)
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 913fb82 commit 45d3aa3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

plugins/out_http/http.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int http_post(struct flb_out_http *ctx,
114114
const char *tag, int tag_len,
115115
char **headers)
116116
{
117-
int ret;
117+
int ret = 0;
118118
int out_ret = FLB_OK;
119119
int compressed = FLB_FALSE;
120120
size_t b_sent;
@@ -143,26 +143,34 @@ static int http_post(struct flb_out_http *ctx,
143143
payload_size = body_len;
144144

145145
/* Should we compress the payload ? */
146+
ret = 0;
146147
if (ctx->compress_gzip == FLB_TRUE) {
147148
ret = flb_gzip_compress((void *) body, body_len,
148149
&payload_buf, &payload_size);
150+
if (ret == 0) {
151+
compressed = FLB_TRUE;
152+
}
149153
}
150154
else if (ctx->compress_snappy == FLB_TRUE) {
151155
ret = flb_snappy_compress((void *) body, body_len,
152-
&payload_buf, &payload_size);
156+
(char **) &payload_buf, &payload_size);
157+
if (ret == 0) {
158+
compressed = FLB_TRUE;
159+
}
153160
}
154161
else if (ctx->compress_zstd == FLB_TRUE) {
155162
ret = flb_zstd_compress((void *) body, body_len,
156163
&payload_buf, &payload_size);
164+
if (ret == 0) {
165+
compressed = FLB_TRUE;
166+
}
157167
}
158168

159169
if (ret == -1) {
160170
flb_plg_warn(ctx->ins, "could not compress payload, sending as it is");
161171
compressed = FLB_FALSE;
162172
}
163-
else {
164-
compressed = FLB_TRUE;
165-
}
173+
166174

167175
/* Create HTTP client context */
168176
c = flb_http_client(u_conn, FLB_HTTP_POST, ctx->uri,

0 commit comments

Comments
 (0)