Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/flb_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ static void http_headers_destroy(struct flb_http_client *c)
int flb_http_set_keepalive(struct flb_http_client *c)
{
/* check if 'keepalive' mode is enabled in the Upstream connection */
if (flb_stream_is_keepalive(c->u_conn->stream)) {
if (flb_stream_is_keepalive(c->u_conn->stream) == FLB_FALSE) {
return -1;
}

Expand Down Expand Up @@ -1149,6 +1149,9 @@ int flb_http_do(struct flb_http_client *c, size_t *bytes)
size_t bytes_body = 0;
char *tmp;

/* Try to add keep alive header */
flb_http_set_keepalive(c);

/* Append pending headers */
ret = http_headers_compose(c);
if (ret == -1) {
Expand Down
4 changes: 4 additions & 0 deletions src/flb_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,10 @@ int flb_output_upstream_set(struct flb_upstream *u, struct flb_output_instance *
flags |= FLB_IO_IPV6;
}

if (ins->net_setup.keepalive == FLB_TRUE) {
flags |= FLB_IO_TCP_KA;
}

/* Set flags */
flb_stream_enable_flags(&u->base, flags);

Expand Down
2 changes: 1 addition & 1 deletion tests/internal/http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct test_ctx* test_ctx_create()
return NULL;
}

ret_ctx->u = flb_upstream_create(ret_ctx->config, "127.0.0.1", 80, 0, NULL);
ret_ctx->u = flb_upstream_create(ret_ctx->config, "127.0.0.1", 80, FLB_IO_TCP_KA, NULL);
if (!TEST_CHECK(ret_ctx->u != NULL)) {
TEST_MSG("flb_upstream_create failed");
flb_config_exit(ret_ctx->config);
Expand Down