mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-26 02:58:43 +02:00
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.
This commit is contained in:
parent
41a2148be4
commit
b68a44d047
@ -493,31 +493,8 @@ void InfluxdbCommonWriter::FlushWQ()
|
||||
auto& response (parser.get());
|
||||
|
||||
if (response.result() != http::status::no_content) {
|
||||
Log(LogWarning, GetReflectionType()->GetName())
|
||||
<< "Unexpected response code: " << response.result();
|
||||
|
||||
auto& contentType (response[http::field::content_type]);
|
||||
if (contentType != "application/json") {
|
||||
Log(LogWarning, GetReflectionType()->GetName())
|
||||
<< "Unexpected Content-Type: " << contentType;
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary::Ptr jsonResponse;
|
||||
auto& body (response.body());
|
||||
|
||||
try {
|
||||
jsonResponse = JsonDecode(body);
|
||||
} catch (...) {
|
||||
Log(LogWarning, GetReflectionType()->GetName())
|
||||
<< "Unable to parse JSON response:\n" << body;
|
||||
return;
|
||||
}
|
||||
|
||||
String error = jsonResponse->Get("error");
|
||||
|
||||
Log(LogCritical, GetReflectionType()->GetName())
|
||||
<< "InfluxDB error message:\n" << error;
|
||||
<< "Unexpected response code: " << response.result() << ", InfluxDB error message:\n" << response.body();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user