Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom StreamingCallbackToken for http_request_streaming_callback #11

Open
lastmjs opened this issue Dec 6, 2021 · 2 comments
Open

Comments

@lastmjs
Copy link

lastmjs commented Dec 6, 2021

Also on the forum: https://forum.dfinity.org/t/custom-streamingcallbacktoken/9379

This issue has come up while implementing #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?

@lastmjs
Copy link
Author

lastmjs commented Dec 6, 2021

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.

@paulyoung
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants