Skip to content

Commit 32cb4c3

Browse files
authored
fix: get version from X-Influxdb-Version header (#297)
1 parent 3a4bcb0 commit 32cb4c3

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 4.0.0 [unreleased]
22

3+
### Bug Fixes
4+
1. [#297](https://github.com/influxdata/influxdb-client-csharp/pull/297): Get version from `X-Influxdb-Version` header
5+
36
## 4.0.0-rc3 [2022-03-04]
47

58
### Features

Client.Core/Internal/AbstractRestClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private string GetVersion(RestResponse responseHttp)
4949
Arguments.CheckNotNull(responseHttp, "responseHttp");
5050

5151
var value = responseHttp.Headers
52-
.Where(header => header.Name.Equals("X-Influxdb-Version"))
52+
.Where(header => header.Name.Equals("X-Influxdb-Version", StringComparison.OrdinalIgnoreCase))
5353
.Select(header => header.Value.ToString())
5454
.FirstOrDefault();
5555

Client.Test/InfluxDbClientTest.cs

+10
Original file line numberDiff line numberDiff line change
@@ -319,5 +319,15 @@ public void HttpClientIsDisposed()
319319

320320
Assert.AreEqual(true, disposed);
321321
}
322+
323+
[Test]
324+
public async Task VersionIsNotCaseSensitive()
325+
{
326+
MockServer.Given(Request.Create().WithPath("/ping").UsingGet())
327+
.RespondWith(Response.Create().WithStatusCode(204)
328+
.WithHeader("x-influxdb-version", "2.0.0"));
329+
330+
Assert.AreEqual("2.0.0", await _client.VersionAsync());
331+
}
322332
}
323333
}

Client/InfluxDBClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public async Task<string> VersionAsync()
443443
}
444444

445445
/// <summary>
446-
/// The readiness of the InfluxDB 2.0.
446+
/// Check the readiness of InfluxDB Server at startup. It is not supported by InfluxDB Cloud.
447447
/// </summary>
448448
/// <returns>return null if the InfluxDB is not ready</returns>
449449
public async Task<Ready> ReadyAsync()

0 commit comments

Comments
 (0)