fix(clients): verify C# client, read Content-Range from content headers

This commit is contained in:
2026-09-30 22:44:15 +02:00
parent 17bb6ea76d
commit 97bcb44fdc
5 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
| `resolvespec-python` | Python >= 3.11 | ResolveSpec, HeaderSpec, FunctionSpec, WebSocketSpec | yes (61 tests) |
| `resolvespec-go` | Go | ResolveSpec, FunctionSpec | yes (`go test`) |
| `resolvespec-rs` | Rust | ResolveSpec, FunctionSpec | yes (`cargo test`) |
| `resolvespec-cs` | C# (.NET 8) | ResolveSpec, FunctionSpec | **not compiled** |
| `resolvespec-cs` | C# (.NET 8) | ResolveSpec, FunctionSpec | yes (`dotnet test`) |
| `resolvespec-dart` | Dart / Flutter | ResolveSpec, FunctionSpec | yes (`dart test`) |
Wire behaviour is identical across clients; FunctionSpec server quirks are listed in each README.
+1 -1
View File
@@ -2,7 +2,7 @@
.NET 8 client for ResolveSpec (JSON body) and FunctionSpec. `System.Text.Json`, no other dependencies.
> Not compiled or tested yet (no .NET SDK was available). Run `dotnet test tests/` first.
> Tests run with `DOTNET_ROLL_FORWARD=Major` when only a newer runtime than 8.0 is installed.
## Clients
+3 -1
View File
@@ -169,7 +169,9 @@ public sealed class FuncSpecClient
};
if (list)
{
resp.Headers.TryGetValues("Content-Range", out var cr);
// Content-Range is a content header in HttpClient; fall back to response headers.
IEnumerable<string>? cr = null;
if (!resp.Content.Headers.TryGetValues("Content-Range", out cr)) resp.Headers.TryGetValues("Content-Range", out cr);
r.Metadata = MetadataFrom(cr?.FirstOrDefault(), o);
}
return r;
@@ -28,7 +28,7 @@ public sealed class ResolveSpecClient
_ => Convert.ToString(id, System.Globalization.CultureInfo.InvariantCulture),
};
static string[]? BodyId(object? id) => id is IEnumerable<string> e and not string ? e.ToArray() : null;
static string[]? BodyId(object? id) => id is IEnumerable<string> e ? e.ToArray() : null;
string Url(string schema, string entity, string? id)
{
+2 -1
View File
@@ -22,7 +22,8 @@ public class Stub : HttpMessageHandler
Request = request;
Body = request.Content == null ? "" : await request.Content.ReadAsStringAsync(ct);
var r = new HttpResponseMessage(_status) { Content = new StringContent(_json, Encoding.UTF8, "application/json") };
foreach (var (k, v) in _headers) r.Headers.TryAddWithoutValidation(k, v);
foreach (var (k, v) in _headers)
if (!r.Headers.TryAddWithoutValidation(k, v)) r.Content.Headers.TryAddWithoutValidation(k, v);
return r;
}
}