C# bindings: add procedure_http_request support + fix HTTP BSATN wire format to match spacetimedb_lib::http
#3944
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
Rust added procedure-scoped HTTP via the
procedure_http_requestABI (see Rust PR #3684) to C# host bindings.What changed:
BSATN.Runtime/HttpWireTypes.cs) to match exactly the Rust stable types:spacetimedb_lib::http::Requestfields and order:method,headers,timeout,uri,versionspacetimedb_lib::http::Responsefields and order:headers,version,codename: string, value: bytes); no additional metadata is encoded.ProcedureContext.Httpsupport (Runtime/Http.cs) that:HttpRequestWire+ sends body bytes viaprocedure_http_requestHttpResponseWireand returns(response, body)as a typedHttpResponseHTTP_ERROR, decodes the error payload as a BSATNstringWOULD_BLOCK_TRANSACTION, returns a stable error message (host rejects blocking HTTP while a mut tx is open)procedure_http_requestimport to the C# wasm shim (Runtime/bindings.c) under thespacetime_10.3import module.[BytesSource; 2]).Runtime/Internal/Module.call_procedure): it must either returnErrno.OKor trap (log + rethrow). This mirrors the host’s expectations and avoids “unexpected errno values from guest entrypoints” behavior.Behavioral notes vs Rust
expect(...)/panic on “should never happen” serialization failures; C# runtime explicitly avoids throwing across the procedure boundary for the HTTP client path and instead returnsResult.Errfor unexpected failures. This prevents whole-module traps from user-space HTTP usage while still surfacing rich errors.API and ABI breaking changes
No new host ABI introduced, and does not change the syscall signature.
Adds API:
ProcedureContextBase.Httpis available for proceduresNo existing public types/method signatures are removed
expect(...)s and may panic/trap on internal “should not happen” cases. On the other hand, C#'sHttpClient.Sendexplicitly converts unexpected failures intoResult.Errto avoid trapping the module. This is a behavioral difference, but not an API break.Expected complexity level and risk
2 - Mostly just creating equivalents to the Rust version.
Testing
C# regression tests updated to cover:
ReadMySchemaViaHttp)InvalidHttpRequest) returning error without trappingTesting performed:
Success.