From 0611ecb97b26b3010630551ddd8abf0756836293 Mon Sep 17 00:00:00 2001 From: "krystian.panek" Date: Thu, 27 Jun 2019 09:24:52 +0200 Subject: [PATCH] HTTP options per instance (hook) --- .../gradle/aem/common/instance/InstanceHttpClient.kt | 2 +- .../cognifide/gradle/aem/common/instance/InstanceOptions.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/cognifide/gradle/aem/common/instance/InstanceHttpClient.kt b/src/main/kotlin/com/cognifide/gradle/aem/common/instance/InstanceHttpClient.kt index b5e85c6e6..5a1af7470 100644 --- a/src/main/kotlin/com/cognifide/gradle/aem/common/instance/InstanceHttpClient.kt +++ b/src/main/kotlin/com/cognifide/gradle/aem/common/instance/InstanceHttpClient.kt @@ -13,7 +13,7 @@ open class InstanceHttpClient(aem: AemExtension, val instance: Instance) : HttpC basicPassword = instance.password authorizationPreemptive = true - apply(aem.instanceOptions.httpOptions) + apply { aem.instanceOptions.httpOptions(this, instance) } } override fun checkStatus(response: HttpResponse, checker: (Int) -> Boolean) { diff --git a/src/main/kotlin/com/cognifide/gradle/aem/common/instance/InstanceOptions.kt b/src/main/kotlin/com/cognifide/gradle/aem/common/instance/InstanceOptions.kt index 8db56b9f8..4ab0bc3d8 100644 --- a/src/main/kotlin/com/cognifide/gradle/aem/common/instance/InstanceOptions.kt +++ b/src/main/kotlin/com/cognifide/gradle/aem/common/instance/InstanceOptions.kt @@ -21,12 +21,12 @@ open class InstanceOptions(private val aem: AemExtension) : Serializable { * - customize maximum time after which initializing connection to AEM will be aborted (e.g on upload, install), * - customize any options offered by Apache HTTP Client builder (use its API directly). */ - fun http(options: InstanceHttpClient.() -> Unit) { + fun http(options: InstanceHttpClient.(Instance) -> Unit) { httpOptions = options } @get:JsonIgnore - internal var httpOptions: InstanceHttpClient.() -> Unit = { + internal var httpOptions: InstanceHttpClient.(Instance) -> Unit = { connectionTimeout = aem.props.int("instance.http.connectionTimeout") ?: 30000 connectionRetries = aem.props.boolean("instance.http.connectionRetries") ?: true connectionIgnoreSsl = aem.props.boolean("instance.http.connectionIgnoreSsl") ?: true