HttpClientSettings.kt

  1. package com.hexagontk.http.client

  2. import com.hexagontk.http.SslSettings
  3. import com.hexagontk.http.model.*
  4. import java.net.URI

  5. // TODO Add proxy configuration and timeouts
  6. class HttpClientSettings(
  7.     val baseUri: URI? = null,
  8.     val contentType: ContentType? = null,
  9.     val accept: List<ContentType> = emptyList(),
  10.     val useCookies: Boolean = true,
  11.     val headers: Headers = Headers(),
  12.     val insecure: Boolean = false,
  13.     val sslSettings: SslSettings? = null,
  14.     val authorization: Authorization? = null,
  15.     val followRedirects: Boolean = false,
  16. ) {
  17.     fun with(
  18.         baseUri: URI? = this.baseUri,
  19.         contentType: ContentType? = this.contentType,
  20.         accept: List<ContentType> = this.accept,
  21.         useCookies: Boolean = this.useCookies,
  22.         headers: Headers = this.headers,
  23.         insecure: Boolean = this.insecure,
  24.         sslSettings: SslSettings? = this.sslSettings,
  25.         authorization: Authorization? = this.authorization,
  26.         followRedirects: Boolean = this.followRedirects,
  27.     ): HttpClientSettings =
  28.         HttpClientSettings(
  29.             baseUri,
  30.             contentType,
  31.             accept,
  32.             useCookies,
  33.             headers,
  34.             insecure,
  35.             sslSettings,
  36.             authorization,
  37.             followRedirects
  38.         )
  39. }