orca-zhang / influxdb-cpp

💜 C++ client for InfluxDB.
MIT License
163 stars 83 forks source link

post_http has a bug when using usr and pwd. #46

Closed fyr233 closed 7 months ago

fyr233 commented 7 months ago

When using post_http and using usr and pwd in server_info,

influxdb_cpp::server_info si("127.0.0.1", 8086, "db", "usr", "pwd");
std::string resp;
influxdb_cpp::builder()
    .meas("foo")
    .tag("k", "v")
    .tag("x", "y")
    .field("x", 10)
    .field("y", 10.3, 2)
    .field("z", 10.3456)
    .field("b", !!10)
    .timestamp(1512722735522840439)
    .post_http(si, &resp);

&resp will get 401 {"error":"unable to parse authentication credentials"}

Maybe the condition si.token_.empty() in code here has problem: image

When I replace si.token_.empty() with !si.token_.empty(), it works.

orca-zhang commented 7 months ago

Thanks a ton to your feedback.