-
Notifications
You must be signed in to change notification settings - Fork 32
/
InstanceHttpClient.kt
29 lines (23 loc) · 1.15 KB
/
InstanceHttpClient.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.cognifide.gradle.aem.common.instance
import com.cognifide.gradle.aem.AemExtension
import com.cognifide.gradle.aem.common.http.HttpClient
import com.cognifide.gradle.aem.common.http.ResponseException
import org.apache.http.HttpResponse
@Suppress("MagicNumber")
open class InstanceHttpClient(aem: AemExtension, val instance: Instance) : HttpClient(aem) {
init {
baseUrl = instance.httpUrl
basicUser = instance.user
basicPassword = instance.password
authorizationPreemptive = true
connectionTimeout = aem.props.int("instance.http.connectionTimeout") ?: 30000
connectionRetries = aem.props.boolean("instance.http.connectionRetries") ?: true
connectionIgnoreSsl = aem.props.boolean("instance.http.connectionIgnoreSsl") ?: true
proxyHost = aem.props.string("instance.http.proxyHost")
proxyPort = aem.props.int("instance.http.proxyPort")
proxyScheme = aem.props.string("instance.http.proxyScheme")
}
override fun throwStatusException(response: HttpResponse) {
throw ResponseException("Instance error. Unexpected response from $instance: ${response.statusLine}")
}
}