Skip to content

📡 Network Request Inspector & Mocking

Flocon captures all outgoing network requests made by your Android or Kotlin Multiplatform app — whether they are simple REST calls or multipart uploads — and displays them in a clean, real-time desktop UI.


Overview

Network Inspector UI

Network Request Detail View

For every captured request, Flocon provides:

  • Method & URL: HTTP method (GET, POST, PUT, DELETE, etc.) and full endpoint URL
  • Headers & Body: Formatted JSON/text request and response payloads with search & copy
  • Metrics: HTTP status code, response time duration, payload size, and timestamps
  • Error Details: Clear diagnostics on connection drops, timeouts, and server errors

🎭 HTTP Request Mocking

Flocon allows you to mock HTTP requests on the fly without editing your codebase or redeploying your application:

Network Mocking in Flocon

  • Simulate Network Errors: Test 401 Unauthorized, 404 Not Found, 429 Rate Limit, or 500 Internal Server Error handling.
  • Custom Response Payloads: Inject mock JSON data to test unreleased backend features or rare edge cases.
  • Clone from Existing Request: Convert any captured real request into an active mock with a single click in the desktop UI.

Step-by-Step Mocking Tutorial


📉 Bad Network Simulation (Network Conditioning)

Flocon also includes a built-in network conditioner to simulate real-world conditions like subway network drops, slow 2G/3G speeds, high latency jitter, and random packet loss without modifying device OS settings.

Bad Network Simulation Guide


Setup & Integration

The interceptors report to the network plugin: add flocon-network-core and install it.

startFlocon(context) {
    install(FloconNetwork)
}

Without FloconNetwork, the interceptors let the calls go through untouched.

With OkHttp (Android & JVM)

[libraries]
flocon-network = { module = "io.github.openflocon:flocon-network-core", version.ref = "flocon" }
flocon-network-no-op = { module = "io.github.openflocon:flocon-network-core-no-op", version.ref = "flocon" }
flocon-okhttp = { module = "io.github.openflocon:flocon-okhttp-interceptor", version.ref = "flocon" }
flocon-okhttp-no-op = { module = "io.github.openflocon:flocon-okhttp-interceptor-no-op", version.ref = "flocon" }
dependencies {
    debugImplementation("io.github.openflocon:flocon-network-core:LAST_VERSION")
    releaseImplementation("io.github.openflocon:flocon-network-core-no-op:LAST_VERSION")
    debugImplementation("io.github.openflocon:flocon-okhttp-interceptor:LAST_VERSION")
    releaseImplementation("io.github.openflocon:flocon-okhttp-interceptor-no-op:LAST_VERSION")
}

Add the interceptor to your OkHttpClient builder:

val okHttpClient = OkHttpClient.Builder()
    .addInterceptor(
        FloconOkhttpInterceptor(
            // optional: display these responses as images
            isImage = { it.request.url.toString().contains("cdn") },
            // optional: calls to skip
            shouldLog = { chain -> !chain.request().url.encodedPath.startsWith("/health") },
        )
    )
    .build()

With Ktor (Kotlin Multiplatform)

[libraries]
flocon-network = { module = "io.github.openflocon:flocon-network-core", version.ref = "flocon" }
flocon-network-no-op = { module = "io.github.openflocon:flocon-network-core-no-op", version.ref = "flocon" }
flocon-ktor = { module = "io.github.openflocon:flocon-ktor-interceptor", version.ref = "flocon" }
flocon-ktor-no-op = { module = "io.github.openflocon:flocon-ktor-interceptor-no-op", version.ref = "flocon" }
kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation("io.github.openflocon:flocon-network-core:LAST_VERSION")
            implementation("io.github.openflocon:flocon-ktor-interceptor:LAST_VERSION")
        }
    }
}

For release builds, see Release builds.

Install the plugin into your Ktor HttpClient:

val httpClient = HttpClient {
    install(FloconKtorPlugin) {
        // optional
        isImage = { it.responseContentType?.startsWith("image/") == true }
        shouldLog = { request -> request.url.host != "localhost" }
    }
}

Ktor Compatibility

Built and tested with Ktor 3.x.