kohttp
  • Introduction
  • Core
    • Synchronous calls
      • GET
      • POST
      • PUT
      • HEAD
      • DELETE
      • PATCH
      • Generic requests
      • Upload files
    • Asynchronous calls
      • async GET
      • async POST
      • async PUT
      • async HEAD
      • async DELETE
      • async PATCH
      • async Generic requests
      • async Upload files
    • Response usage
    • Interceptors
    • Customisation
    • Experimental features
  • History
    • Changelog
Powered by GitBook
On this page
  • defaultClientPool customization
  • Fork HttpClient for specific tasks
  • Run HTTP methods on custom client

Was this helpful?

  1. Core

Customisation

defaultClientPool customization

Kohttp provides a defaultClientPool to have a single endpoint for your http request.

Fork HttpClient for specific tasks

Forked client uses exactly the same connection pool and dispatcher. However, it will custom parameters like custom timeouts, additional interceptors or others.

In this example below patientClient will share ConnectionPool with defaultHttpClient, however patientClient requests will have custom read timeout.

val patientClient = defaultHttpClient.fork {   
    readTimeout = 100_000 
}

Run HTTP methods on custom client

If defaultClientPool or forked client does not suit you for some reason, it is possible to create your own one.

// a new client with custom dispatcher, connection pool and ping interval
val customClient = client {
    dispatcher = ...
    connectionPool = ConnectionPool( ... )
    pingInterval = 1_000
    sslConfig = SslConfig().apply {
        sslSocketFactory = ...
        trustManager = ...
        hostnameVerifier = ...
        certificatePinner = ...
        followSslRedirects = ...
    }
}
PreviousInterceptorsNextExperimental features

Last updated 5 years ago

Was this helpful?