Custom StreamingCallbackToken for http_request_streaming_callback
Also on the forum: https://forum.dfinity.org/t/custom-streamingcallbacktoken/9379
This issue has come up while implementing https://github.com/dfinity/certified-assets/issues/10
I would like some clarification on StreamingCallbackToken and http_request_streaming_callback. I might need to modify the StreamingCallbackToken or implement a custom http_request_streaming_callback, but I am not sure if I am able to do that.
Is http_request_streaming_callback a special function? I assume I could name the function anything I want when creating StreamingStrategy::Callback, is that correct?
If that's the case, can I also change the StreamingCallbackToken parameter?
The problem I am trying to solve is that of 206 Partial Content responses. I need to return very custom slices of content, because the client could request any range of bytes on an asset. The default http_request_streaming_callback does not quite offer the flexibility I need. I think I can hack it with the current StreamingCallbackToken, but is there a possibility of implementing my own?
Maybe a simpler question is, can I implement custom streaming strategies? If so, how would I do that?
There is this StreamingStrategy enum:
enum StreamingStrategy {
Callback {
callback: Func,
token: StreamingCallbackToken,
},
}
I would like to somehow provide a custom callback and token to implement my special strategy.
I suspect you’d need to extend StreamingStrategy here: https://github.com/dfinity/agent-rs/blob/a8bb38e2079c935fc4deec0128c05319a43e5551/ic-utils/src/interfaces/http_request.rs#L39
and then match on it here, providing the implementation: https://github.com/dfinity/icx-proxy/blob/6cee84ace323c846f670d2eefdd292aa1b986f08/src/main.rs#L261