OkHttpPorthole

OkHttp integration.

Two hooks, because neither alone is enough:

  • an EventListener for the phase a call is stuck in. "Waiting on response headers for 8 seconds" is usually the whole answer, and only the listener can see it.

  • an Interceptor for bodies, which the listener only ever sees as byte counts. Off by default; see BodyCapture.

Functions

Link copied to clipboard
fun bodyInterceptor(bodies: BodyCapture = BodyCapture.Text): Interceptor

The body-capturing half on its own, if you already have a listener wired up.

Link copied to clipboard
fun eventListenerFactory(delegate: EventListener.Factory? = null): EventListener.Factory

Use this directly if you build your client somewhere awkward.

Link copied to clipboard
fun OkHttpClient.Builder.installPorthole(existing: EventListener.Factory? = null, bodies: BodyCapture = BodyCapture.Off): OkHttpClient.Builder

Installs the porthole on a builder.