Custom StreamingCallbackToken

Also on GitHub: Custom StreamingCallbackToken for http_request_streaming_callback · Issue #11 · dfinity/certified-assets · GitHub

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 think you have to abide by this interface (since it’s what the Rust icx-proxy that’s running on the boundary node will expect and parse).

So you can name the function anything you want (doesn’t have to be http_request_streaming_callback) but you can’t change the token parameter I don’t think.

The code where the icx-proxy actually calls your asset canister is here.

1 Like

Based on my understanding of the icx-proxy code, I don’t think range requests like this are supported.

1 Like

Yep, I’m implementing range requests. I might need to pull request into the icx-proxy code then. I can hack what I want with the current limitations, it just won’t be pretty.

Thanks for confirming my suspicions.

Do you know if the boundary nodes run icx-proxy? Is the boundary node software open source?

Basically, I might need to change the boundary node code, how do I do that? Pull requests might be necessary

Yeah the boundary nodes run icx-proxy. I believe it may have recently been open sourced, see this for details.

The real question is are the boundary nodes decentralized, i.e. managed by the NNS and thus upgradable via NNS proposals. And I think the answer is no… hoping to get more clarity on this here.

2 Likes