BridgeHttpHandler
Namespace: BlazorNative.Http
An System.Net.Http.HttpMessageHandler that routes every request through
BlazorNative.Core.IMobileBridge.FetchAsync(BlazorNative.Core.BridgeHttpRequest,System.Threading.CancellationToken) instead of .NET's socket-based
HttpClientHandler, so the native shell performs the actual HTTP request
(its networking stack, proxies and certificates) and returns the response across
the bridge. Registered as the primary handler by ServiceCollectionExtensions.AddBlazorNativeHttp(IServiceCollection),
so ordinary HttpClient injection works unchanged on NativeAOT.
public sealed class BridgeHttpHandler : System.Net.Http.HttpMessageHandler, System.IDisposable
Inheritance Object → HttpMessageHandler → BridgeHttpHandler
Implements IDisposable
Attributes NullableContextAttribute, NullableAttribute, TransientAttribute
Remarks:
Responses are fully buffered — there is no streaming. The bridge delivers a
response as one complete BlazorNative.Core.BridgeHttpResponse when the request finishes; the
shell buffers the whole body and hands it over once, so this handler never sees a partial
body and cannot expose one. HttpCompletionOption.ResponseHeadersRead,
ReadAsStreamAsync and friends still work, but they yield the already-complete body.
Server-Sent Events, chunked responses read incrementally, and long-polling therefore
degrade to "wait for the whole response" — effectively polling — and there is no
backpressure because nothing is incremental. Streaming would be an ABI-shaped change (an
incremental delivery path beside the one-shot completion), so it is a roadmap item, not a
configuration switch.
Bodies are text (UTF-8). The response body crosses the bridge as a UTF-8
string and is exposed as StringContent; the request body is read with
ReadAsStringAsync before dispatch. Binary or non-UTF-8 payloads in either direction
are unsupported — download files or images through a shell capability that returns a
path (the camera pattern), not through this handler.
Constructors
BridgeHttpHandler(IMobileBridge)
Creates the handler over the host bridge that performs the fetch.
public BridgeHttpHandler(IMobileBridge bridge)
Parameters
bridge IMobileBridge
The bridge whose BlazorNative.Core.IMobileBridge.FetchAsync(BlazorNative.Core.BridgeHttpRequest,System.Threading.CancellationToken) the
handler dispatches each request through.