Hei, Just curious why content is marked as interna...
# ktor
s
Hei, Just curious why content is marked as internal ? When used together with ResponseObserver, Then I have to use OptIn internal api annotation. I use ResponseObserver to log response body. I donot want to use bodyAsChannel, as it may contain modified response. https://github.com/ktorio/ktor/blob/main/ktor-client/ktor-client-core/common/src/io/ktor/client/statement/HttpResponse.kt#L55-L56
a
@Rustam Siniukov
r
Because
content
is raw response and we want to discourage its usage. If you know what you do, just use
@OptIn
, should be safe.
s
Are there plans to expose it in some other way then, I mean raw response in combination with ResponseObserver is especially helpful
r
If we get more use cases to come up with a good API for it, then yes.
s
Okay. With the risk of being a little pushy, doesn’t the motivation of
ResponseObserver
class remains incomplete if one cannot observer complete response (meaning, reading the response body, and perhaps using it in the handler) ?
Could ResponseObserver then provide, httpResponse, and content as predicates to the handler, so we can use it in our cases ?
just like
ResponseBodyReadyForSend
Hook ? (a server hook I know, but pointing it out as a feature)
r
No worries, explaining your use cases is always welcome! In this case we will make it really easy to access raw body, which is usually discouraged. Imagine you have gzip encoding in your response. There is not much sense in accessing it as it is. But if callback will receive it as a parameter, users will almost for certain try to read it instead of calling
.bodyAsChannel()
Maybe we need to create an annotation similar to
@DangerousApi
in coroutines, and use it here instead of
@InternalApi
.
ResponseBodyReadyForSend
receives processed body with all the transformations applied,
.content
is just bytes that we read from the network
s
Yeah, that makes sense, just a naive question. Apart from byteBuffer to concrete type transformtion when
.bodyAsChannel
is called, are there other transformations one can expect in HttpResponsePipeline ?
r
Mostly transforming and content encoding
s
Thank you 🙂
👍 1