@@ -890,28 +890,21 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk,
890
890
flb_http_basic_auth (c , ctx -> cloud_user , ctx -> cloud_passwd );
891
891
}
892
892
else if (ctx -> http_api_key ) {
893
- header_buffer = flb_sds_create_size ( strlen ( ctx -> http_api_key ) + 64 );
894
-
895
- if ( header_buffer == NULL ) {
896
- flb_error ( "[out_es] failed to create header buffer" ) ;
893
+ header_line = flb_sds_printf ( NULL , "ApiKey %s" , ctx -> http_api_key );
894
+ if ( header_line == NULL ) {
895
+ flb_plg_error ( ctx -> ins , "failed to format API key auth header" );
896
+ goto retry ;
897
897
}
898
- else {
899
- header_line = flb_sds_printf (& header_buffer , "ApiKey %s" , ctx -> http_api_key );
900
-
901
- if (header_line != NULL ) {
902
- flb_http_add_header (c ,
903
- FLB_HTTP_HEADER_AUTH ,
904
- strlen (FLB_HTTP_HEADER_AUTH ),
905
- header_line ,
906
- flb_sds_len (header_line ));
907
- }
908
- else {
909
- flb_sds_destroy (header_buffer );
910
- goto error ;
911
- }
912
898
913
- flb_sds_destroy (header_buffer );
899
+ if (flb_http_add_header (c ,
900
+ FLB_HTTP_HEADER_AUTH , strlen (FLB_HTTP_HEADER_AUTH ),
901
+ header_line , flb_sds_len (header_line )) != 0 ) {
902
+ flb_plg_error (ctx -> ins , "failed to add API key auth header" );
903
+ flb_sds_destroy (header_line );
904
+ goto retry ;
914
905
}
906
+
907
+ flb_sds_destroy (header_line );
915
908
}
916
909
917
910
#ifdef FLB_HAVE_AWS
0 commit comments