Skip to content

Commit d894012

Browse files
committed
Don't expect Contet-Type header to exactly match application/json
InfluxDB seems to always include some other metadata in the `Content-Type` header separated by semicolons like `application/json; charset=utf-8`, and comparing the whole string with `application/json` will always fail, resulting in almost always useless warnings without any helpful information for the user what actually went wrong.
1 parent 2063d2b commit d894012

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/perfdata/influxdbcommonwriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ void InfluxdbCommonWriter::FlushWQ()
497497
<< "Unexpected response code: " << response.result();
498498

499499
auto& contentType (response[http::field::content_type]);
500-
if (contentType != "application/json") {
500+
if (contentType != "application/json" && contentType != "application/json; charset=utf-8") {
501501
Log(LogWarning, GetReflectionType()->GetName())
502502
<< "Unexpected Content-Type: " << contentType;
503503
return;
@@ -517,7 +517,7 @@ void InfluxdbCommonWriter::FlushWQ()
517517
String error = jsonResponse->Get("error");
518518

519519
Log(LogCritical, GetReflectionType()->GetName())
520-
<< "InfluxDB error message:\n" << error;
520+
<< "InfluxDB error message: " << error << " :\n" << body;
521521
}
522522
}
523523

0 commit comments

Comments
 (0)