OkHttpSender
The default NetworkSender, backed by an OkHttp OkHttpClient.
The Network tab's Send form lists each sender by its name, and resolves a relative URL against its baseUrl. Register several with NetworkDebugTab.create(senders = ...), one for each client that the app builds with its own interceptors or for its own host:
NetworkDebugTab.create(
senders = listOf(
OkHttpSender.create("API (signed in)", baseUrl = "https://api.example.com") { apiClient },
OkHttpSender.create("CDN", baseUrl = "https://cdn.example.com") { cdnClient },
),
)When the app can change its server at runtime, such as with a server picker in a debug menu, give the base URL as a function, which the tab calls for each send and each time it lists the senders:
OkHttpSender.create("API", baseUrlProvider = { serverSettings.currentBaseUrl }) { apiClient }The runtime invokes send off the main thread and blocks for the result; this implementation issues a synchronous OkHttp call. A sent request appears as its own row in the traffic list only when the client carries the Lustro interceptor. Otherwise the Send form still reports the outcome (status, success), but the request is not captured.
At most 256 KB of the response body is read into NetworkSendResult.body. The response is then closed without reading the rest, so a large or endless response cannot exhaust the heap.
Constructors
Types
Factories for OkHttpSender.
Functions
Sends request synchronously and maps the outcome to a NetworkSendResult.