Ulf
05/08/2025, 2:33 PMHttpCache plugin. We've also made a custom logging plugin based on similar code as in the Logging plugin.
However, one difference from the Logging plugin is that we would like to log the response even if nothing is sent over the network, ie the cached item is valid and returned directly (see for example HttpCache.proceedWithCache). Logging the response body becomes problematic and I'm unsure how to solve that. In the Logging plugin the ResponseObserver which is running in the receivePipeline is used to split the ByteReadChannel that contains the rawContent so that one is used for logging, but when response comes from cache the receivePipeline will never run. I can intercept the response in the responsePipeline though, but am unsure how to handle it here so that i can both log it and have the channel possible to consume later when reading the body, i've tried to something similar with split( ) as in ResponseObserver but so far failed...
(the response body is there but hidden as responseBody in SavedHttpCall, so if one could access it directly things would be quite simple...)Aleksei Tirman [JB]
05/09/2025, 8:58 AMUlf
05/09/2025, 8:59 AMproceedWithWarning case it's not even a SavedHttpCallAleksei Tirman [JB]
05/09/2025, 9:01 AMUlf
05/09/2025, 9:01 AMAleksei Tirman [JB]
05/09/2025, 9:02 AMUlf
05/09/2025, 9:03 AMUlf
05/09/2025, 9:04 AMUlf
05/09/2025, 9:04 AMUlf
05/09/2025, 9:06 AMUlf
05/09/2025, 9:09 AMresponsePipeline instead as mentioned, checked if the subject was a ByteReadChannel, tried splitting it as in ResponseObserver, and passing one part further down the pipelines and keeping one for logging.. But couldn't get that to work...Aleksei Tirman [JB]
05/09/2025, 9:24 AMSavedHttpResponse.isSaved returns false when the HttpCache plugin proceeds with the cached response. For the proceedWithWarning case, you can use the ByteReadChannel.split method to log the response body while leaving the original one unconsumed.
I've filed an issue to support logging the cached calls with the OkHttp logging format. I assume there should be an option to enable/disable logging of the cached calls. Do you think the cached calls should be logged by default?Ulf
05/09/2025, 9:27 AM