+ }
+
+ private fun basicHeaders(headers: Map<String, String>?):
+ Array<BasicHeader> {
+ val basicHeaders = mutableListOf<BasicHeader>()
+ defaultHeaders().forEach { (name, value) ->
+ basicHeaders.add(BasicHeader(name, value))
+ }
+ headers?.forEach { name, value ->
+ basicHeaders.add(BasicHeader(name, value))
+ }
+ return basicHeaders.toTypedArray()
+ }
+
+ // Non Blocking Rest Implementation
+ suspend fun httpClientNB(): CloseableHttpClient {
+ return HttpClients.custom()
+ .addInterceptorFirst(WebClientUtils.logRequest())
+ .addInterceptorLast(WebClientUtils.logResponse())
+ .build()
+ }
+
+ // TODO maybe there could be cases where we care about return headers?
+ data class WebClientResponse<T>(val status: Int, val body: T)
+
+ fun verifyAdditionalHeaders(restClientProperties: RestClientProperties): Map<String, String> {
+ val customHeaders: MutableMap<String, String> = mutableMapOf()
+ // Extract additionalHeaders from the requestProperties and
+ // throw an error if HttpHeaders.AUTHORIZATION key (headers are case-insensitive)
+ restClientProperties.additionalHeaders?.let {
+ if (it.keys.map { k -> k.toLowerCase().trim() }.contains(HttpHeaders.AUTHORIZATION.toLowerCase())) {
+ val errMsg = "Error in definition of endpoint ${restClientProperties.url}." +
+ " User-supplied \"additionalHeaders\" cannot contain AUTHORIZATION header with" +
+ " auth-type \"${RestLibConstants.TYPE_BASIC_AUTH}\""
+ WebClientUtils.log.error(errMsg)
+ throw BluePrintProcessorException(errMsg)
+ } else {
+ customHeaders.putAll(it)
+ }