KtorHttpTransport
//fluxbase-kotlin/io.github.nimbleflux.fluxbase.core/KtorHttpTransport
KtorHttpTransport
Section titled “KtorHttpTransport”[jvm]
class KtorHttpTransport(baseUrl: String, json: Json = FluxbaseHttpClient.defaultJson, timeoutMillis: Long, trustAllCertificates: Boolean = false) : HttpTransport
Ktor-backed HttpTransport — the production HTTP implementation for JVM/Android.
This is the equivalent of the TS SDK’s FluxbaseFetch class which wraps global.fetch(). It handles the actual TCP I/O, JSON serialization of the request body, and status-code-to-exception conversion.
Two response paths:
- request returns the body as text (for JSON APIs).
- requestBytes returns the body as raw bytes (binary-safe, for storage downloads and any other non-text payload) — the Kotlin analogue of the TS
getBlob. Bytes never pass through a charset decode, so images and other non-UTF-8 payloads survive intact.
Request bodies:
- ByteArray bodies are sent raw (binary-safe, used by storage upload).
- Anything else is JSON-encoded via encodeToJsonElement, matching how the TS SDK passes plain JS objects through
JSON.stringify.
The full port (S1) will add: 30s timeout, 401 auto-refresh+retry (single shared refresh, deduped across concurrent requests). For the S0 spike this minimal version proves the wire contract end-to-end.
Constructors
Section titled “Constructors”| KtorHttpTransport | [jvm] constructor(baseUrl: String, json: Json = FluxbaseHttpClient.defaultJson, timeoutMillis: Long, trustAllCertificates: Boolean = false) |
Functions
Section titled “Functions”| Name | Summary |
|---|---|
| request | [jvm] open suspend override fun request(method: HttpMethod, path: String, body: Any?, headers: Map<String, String>): HttpResponse Perform an HTTP method request to path (relative to the base URL). body is a pre-serialized value (will be JSON-encoded by the transport) or null for GET/DELETE/HEAD. headers are per-request overrides merged on top of the client defaults. Returns the raw response body as text. |
| requestBytes | [jvm] open suspend override fun requestBytes(method: HttpMethod, path: String, headers: Map<String, String>): ByteArray Perform an HTTP method request and return the response body as raw bytes — the binary-safe path used by FluxbaseHttpClient.getBytes (e.g. storage downloads). Unlike request, the body never passes through a text/charset decode, so non-UTF-8 bytes (images, archives) survive intact. Mirrors the TS SDK’s getBlob in sdk/src/fetch.ts. |