Skip to content

Commit

Permalink
Added more log information hexagontk#272
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpascal1 committed Mar 19, 2020
1 parent 5ca4cd1 commit 04db141
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hexagon_web/src/main/kotlin/com/hexagonkt/web/Web.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hexagonkt.web

import com.hexagonkt.helpers.logger
import java.util.Locale.forLanguageTag as localeFor

import com.hexagonkt.http.server.Call
Expand All @@ -14,6 +15,8 @@ fun Call.templateType(template: String) {
if (response.contentType == null) {
val mimeType = SerializationManager.contentTypeOf(template.substringAfterLast('.'))
response.contentType = "$mimeType; charset=${defaultCharset().name()}"
logger.trace { response }
logger.trace { response.contentType }
}
}

Expand All @@ -22,6 +25,7 @@ fun Call.fullContext(): Map<String, *> {
"path" to request.path.removeSuffix("/"), // Do not allow trailing slash
"lang" to obtainLocale().language
)
logger.trace { extraParameters }

return settings + session.attributes + extraParameters
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hexagonkt.http.client.ahc

import com.hexagonkt.helpers.ensureSize
import com.hexagonkt.helpers.logger
import com.hexagonkt.helpers.stream
import com.hexagonkt.serialization.SerializationManager.formatOf
import com.hexagonkt.serialization.serialize
Expand Down Expand Up @@ -106,6 +107,7 @@ class AhcAdapter : ClientPort {
private fun keyStore(uri: URI, password: String): KeyStore {
val keyStore = KeyStore.getInstance("pkcs12")
keyStore.load(uri.stream(), password.toCharArray())
logger.trace { keyStore }
return keyStore
}

Expand All @@ -126,6 +128,7 @@ class AhcAdapter : ClientPort {
}

val response = ahcRequest.execute().get()
logger.trace { response }

if (settings.useCookies) {
response.cookies.forEach {
Expand All @@ -142,6 +145,7 @@ class AhcAdapter : ClientPort {
.map { it to response.headers.getAll(it) }
.toMap()
)
logger.trace { returnHeaders }

return response.let {
Response(
Expand Down Expand Up @@ -179,6 +183,14 @@ class AhcAdapter : ClientPort {
}

ssl = cl.settings

logger.trace { method }
logger.trace { path }
logger.trace { settings }
logger.trace { contentType }
logger.trace { parts }
logger.trace { ssl }

val req = when (method) {
GET -> ahcClient.prepareGet(path)
HEAD -> ahcClient.prepareHead(path)
Expand Down Expand Up @@ -206,6 +218,7 @@ class AhcAdapter : ClientPort {
if (authorization != null)
req.addHeader("Authorization", "Basic $authorization")

logger.trace { req }
return req
}
}

0 comments on commit 04db141

Please sign in to comment.