mirror of https://github.com/usbharu/Hideout.git
feat: 署名されないリクエストもログをとるように
This commit is contained in:
parent
94900cc32c
commit
c1dc1011b3
|
@ -42,6 +42,7 @@ class APRequestServiceImpl(
|
||||||
header("Accept", ContentType.Application.Activity)
|
header("Accept", ContentType.Application.Activity)
|
||||||
header("Date", date)
|
header("Date", date)
|
||||||
}.bodyAsText()
|
}.bodyAsText()
|
||||||
|
logBody(bodyAsText, url)
|
||||||
return objectMapper.readValue(bodyAsText, responseClass)
|
return objectMapper.readValue(bodyAsText, responseClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,15 +82,7 @@ class APRequestServiceImpl(
|
||||||
httpResponse.status,
|
httpResponse.status,
|
||||||
httpResponse.request.url
|
httpResponse.request.url
|
||||||
)
|
)
|
||||||
logger.trace(
|
logBody(bodyAsText, url)
|
||||||
"""
|
|
||||||
|***** BEGIN HTTP Response Trace url: {} *****
|
|
||||||
|
|
|
||||||
|$bodyAsText
|
|
||||||
|
|
|
||||||
|***** END HTTP Response TRACE url: {} *****
|
|
||||||
""".trimMargin(), url, url
|
|
||||||
)
|
|
||||||
return readValue
|
return readValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +109,13 @@ class APRequestServiceImpl(
|
||||||
|
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|***** BEGIN HTTP Request Trace url: {} *****
|
|***** BEGIN HTTP Request Trace url: {} *****
|
||||||
|
|
|
|
||||||
|$requestBody
|
|$requestBody
|
||||||
|
|
|
|
||||||
|***** END HTTP Request Trace url: {} *****
|
|***** END HTTP Request Trace url: {} *****
|
||||||
|
|
|
||||||
""".trimMargin(), url, url
|
""".trimMargin(), url, url
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -131,13 +126,15 @@ class APRequestServiceImpl(
|
||||||
val date = dateTimeFormatter.format(ZonedDateTime.now(ZoneId.of("GMT")))
|
val date = dateTimeFormatter.format(ZonedDateTime.now(ZoneId.of("GMT")))
|
||||||
val u = URL(url)
|
val u = URL(url)
|
||||||
if (signer?.privateKey == null) {
|
if (signer?.privateKey == null) {
|
||||||
return httpClient.post(url) {
|
val bodyAsText = httpClient.post(url) {
|
||||||
header("Accept", ContentType.Application.Activity)
|
header("Accept", ContentType.Application.Activity)
|
||||||
header("Date", date)
|
header("Date", date)
|
||||||
header("Digest", "sha-256=$digest")
|
header("Digest", "sha-256=$digest")
|
||||||
setBody(requestBody)
|
setBody(requestBody)
|
||||||
contentType(ContentType.Application.Activity)
|
contentType(ContentType.Application.Activity)
|
||||||
}.bodyAsText()
|
}.bodyAsText()
|
||||||
|
logBody(bodyAsText, url)
|
||||||
|
return bodyAsText
|
||||||
}
|
}
|
||||||
|
|
||||||
val headers = headers {
|
val headers = headers {
|
||||||
|
@ -177,16 +174,22 @@ class APRequestServiceImpl(
|
||||||
httpResponse.status,
|
httpResponse.status,
|
||||||
httpResponse.request.url
|
httpResponse.request.url
|
||||||
)
|
)
|
||||||
|
logBody(bodyAsText, url)
|
||||||
|
return bodyAsText
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun logBody(bodyAsText: String, url: String) {
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"""
|
"""
|
||||||
|***** BEGIN HTTP Response Trace url: {} *****
|
|
|
||||||
|
|
|***** BEGIN HTTP Response Trace url: {} *****
|
||||||
|$bodyAsText
|
|
|
||||||
|
|
|$bodyAsText
|
||||||
|***** END HTTP Response TRACE url: {} *****
|
|
|
||||||
""".trimMargin(), url, url
|
|***** END HTTP Response TRACE url: {} *****
|
||||||
|
|
|
||||||
|
""".trimMargin(), url, url
|
||||||
)
|
)
|
||||||
return bodyAsText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
Loading…
Reference in New Issue