Skip to content

Commit

Permalink
ktor-client: Add HttpsURLConnection config to AndroidEngineConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jeiea authored and e5l committed Oct 18, 2018
1 parent 9d2831d commit 48f2d89
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Expand Up @@ -13,6 +13,7 @@ import kotlinx.coroutines.io.*
import kotlinx.coroutines.io.jvm.javaio.*
import java.io.*
import java.net.*
import javax.net.ssl.*
import kotlin.coroutines.*

/**
Expand Down Expand Up @@ -47,6 +48,10 @@ class AndroidClientEngine(override val config: AndroidEngineConfig) : HttpClient
connectTimeout = config.connectTimeout
readTimeout = config.socketTimeout

if (this is HttpsURLConnection) {
config.sslManager(this)
}

requestMethod = method.value
useCaches = false
instanceFollowRedirects = false
Expand Down
Expand Up @@ -2,6 +2,7 @@ package io.ktor.client.engine.android

import io.ktor.client.engine.*
import java.net.*
import javax.net.ssl.*


class AndroidEngineConfig : HttpClientEngineConfig() {
Expand All @@ -21,4 +22,9 @@ class AndroidEngineConfig : HttpClientEngineConfig() {
* Proxy address to use - default <code>{@link #openConnection java.net.URL:URL.openConnection}</code>
*/
var proxy: Proxy? = null

/**
* https connection manipulator. inherited methods are not permitted.
*/
var sslManager: (HttpsURLConnection) -> Unit = {}
}

0 comments on commit 48f2d89

Please sign in to comment.