Skip to content

Commit

Permalink
fix: handle unsupported content-types
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Birkett <[email protected]>
  • Loading branch information
portswigger-tim authored and edsiper committed Jun 24, 2024
1 parent 5b81ad7 commit 9ed8cf8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions plugins/in_opentelemetry/opentelemetry_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2191,12 +2191,18 @@ static int process_payload_metrics_ng(struct flb_opentelemetry *ctx,
cfl_sds_len(request->body) - 5,
&offset);
}
else {
else if (strcasecmp(request->content_type, "application/x-protobuf") == 0 ||
strcasecmp(request->content_type, "application/json") == 0) {
result = cmt_decode_opentelemetry_create(&decoded_contexts,
request->body,
cfl_sds_len(request->body),
&offset);
}
else {
flb_plg_error(ctx->ins, "Unsupported content type %s", request->content_type);

return -1;
}

if (result == CMT_DECODE_OPENTELEMETRY_SUCCESS) {
cfl_list_foreach(iterator, &decoded_contexts) {
Expand Down Expand Up @@ -2243,12 +2249,18 @@ static int process_payload_traces_proto_ng(struct flb_opentelemetry *ctx,
cfl_sds_len(request->body) - 5,
&offset);
}
else {
else if (strcasecmp(request->content_type, "application/x-protobuf") == 0 ||
strcasecmp(request->content_type, "application/json") == 0) {
result = ctr_decode_opentelemetry_create(&decoded_context,
request->body,
cfl_sds_len(request->body),
&offset);
}
else {
flb_plg_error(ctx->ins, "Unsupported content type %s", request->content_type);

return -1;
}

if (result == 0) {
result = flb_input_trace_append(ctx->ins, NULL, 0, decoded_context);
Expand Down

0 comments on commit 9ed8cf8

Please sign in to comment.