Skip to content

fix: get version from X-Influxdb-Version header #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 4.0.0 [unreleased]

### Bug Fixes
1. [#297](https://github.com/influxdata/influxdb-client-csharp/pull/297): Get version from `X-Influxdb-Version` header

## 4.0.0-rc3 [2022-03-04]

### Features
Expand Down
2 changes: 1 addition & 1 deletion Client.Core/Internal/AbstractRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private string GetVersion(RestResponse responseHttp)
Arguments.CheckNotNull(responseHttp, "responseHttp");

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

Expand Down
10 changes: 10 additions & 0 deletions Client.Test/InfluxDbClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,5 +319,15 @@ public void HttpClientIsDisposed()

Assert.AreEqual(true, disposed);
}

[Test]
public async Task VersionIsNotCaseSensitive()
{
MockServer.Given(Request.Create().WithPath("/ping").UsingGet())
.RespondWith(Response.Create().WithStatusCode(204)
.WithHeader("x-influxdb-version", "2.0.0"));

Assert.AreEqual("2.0.0", await _client.VersionAsync());
}
}
}
2 changes: 1 addition & 1 deletion Client/InfluxDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public async Task<string> VersionAsync()
}

/// <summary>
/// The readiness of the InfluxDB 2.0.
/// Check the readiness of InfluxDB Server at startup. It is not supported by InfluxDB Cloud.
/// </summary>
/// <returns>return null if the InfluxDB is not ready</returns>
public async Task<Ready> ReadyAsync()
Expand Down