@@ -109,10 +109,10 @@ static void append_headers(struct flb_http_client *c,
109109 }
110110}
111111
112- static int http_post (struct flb_out_http * ctx ,
113- const void * body , size_t body_len ,
114- const char * tag , int tag_len ,
115- char * * headers )
112+ static int http_request (struct flb_out_http * ctx ,
113+ const void * body , size_t body_len ,
114+ const char * tag , int tag_len ,
115+ char * * headers )
116116{
117117 int ret = 0 ;
118118 int out_ret = FLB_OK ;
@@ -173,7 +173,7 @@ static int http_post(struct flb_out_http *ctx,
173173
174174
175175 /* Create HTTP client context */
176- c = flb_http_client (u_conn , FLB_HTTP_POST , ctx -> uri ,
176+ c = flb_http_client (u_conn , ctx -> http_method , ctx -> uri ,
177177 payload_buf , payload_size ,
178178 ctx -> host , ctx -> port ,
179179 ctx -> proxy , 0 );
@@ -541,7 +541,7 @@ static char **extract_headers(msgpack_object *obj) {
541541 return NULL ;
542542}
543543
544- static int post_all_requests (struct flb_out_http * ctx ,
544+ static int send_all_requests (struct flb_out_http * ctx ,
545545 const char * data , size_t size ,
546546 flb_sds_t body_key ,
547547 flb_sds_t headers_key ,
@@ -610,8 +610,10 @@ static int post_all_requests(struct flb_out_http *ctx,
610610 }
611611
612612 if (body_found && headers_found ) {
613- flb_plg_trace (ctx -> ins , "posting record %zu" , record_count ++ );
614- ret = http_post (ctx , body , body_size , event_chunk -> tag ,
613+ flb_plg_trace (ctx -> ins , "sending record %zu via %s" ,
614+ record_count ++ ,
615+ ctx -> http_method == FLB_HTTP_POST ? "POST" : "PUT" );
616+ ret = http_request (ctx , body , body_size , event_chunk -> tag ,
615617 flb_sds_len (event_chunk -> tag ), headers );
616618 }
617619 else {
@@ -643,11 +645,11 @@ static void cb_http_flush(struct flb_event_chunk *event_chunk,
643645 (void ) i_ins ;
644646
645647 if (ctx -> body_key ) {
646- ret = post_all_requests (ctx , event_chunk -> data , event_chunk -> size ,
648+ ret = send_all_requests (ctx , event_chunk -> data , event_chunk -> size ,
647649 ctx -> body_key , ctx -> headers_key , event_chunk );
648650 if (ret < 0 ) {
649651 flb_plg_error (ctx -> ins ,
650- "failed to post requests body key \"%s\"" , ctx -> body_key );
652+ "failed to send requests using body key \"%s\"" , ctx -> body_key );
651653 }
652654 }
653655 else {
@@ -661,15 +663,15 @@ static void cb_http_flush(struct flb_event_chunk *event_chunk,
661663 (ctx -> out_format == FLB_PACK_JSON_FORMAT_STREAM ) ||
662664 (ctx -> out_format == FLB_PACK_JSON_FORMAT_LINES ) ||
663665 (ctx -> out_format == FLB_HTTP_OUT_GELF )) {
664- ret = http_post (ctx , out_body , out_size ,
665- event_chunk -> tag , flb_sds_len (event_chunk -> tag ), NULL );
666+ ret = http_request (ctx , out_body , out_size ,
667+ event_chunk -> tag , flb_sds_len (event_chunk -> tag ), NULL );
666668 flb_sds_destroy (out_body );
667669 }
668670 else {
669671 /* msgpack */
670- ret = http_post (ctx ,
671- event_chunk -> data , event_chunk -> size ,
672- event_chunk -> tag , flb_sds_len (event_chunk -> tag ), NULL );
672+ ret = http_request (ctx ,
673+ event_chunk -> data , event_chunk -> size ,
674+ event_chunk -> tag , flb_sds_len (event_chunk -> tag ), NULL );
673675 }
674676 }
675677
@@ -771,6 +773,11 @@ static struct flb_config_map config_map[] = {
771773 0 , FLB_TRUE , offsetof(struct flb_out_http , uri ),
772774 "Specify an optional HTTP URI for the target web server, e.g: /something"
773775 },
776+ {
777+ FLB_CONFIG_MAP_STR , "http_method" , "POST" ,
778+ 0 , FLB_FALSE , 0 ,
779+ "Specify the HTTP method to use. Supported methods are POST and PUT"
780+ },
774781
775782 /* Gelf Properties */
776783 {
0 commit comments