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

Async streaming of request body and response #396

Open
paulyoung opened this issue Dec 9, 2022 · 1 comment
Open

Async streaming of request body and response #396

paulyoung opened this issue Dec 9, 2022 · 1 comment

Comments

@paulyoung
Copy link
Contributor

Until recently, I was interacting with a canister via the HTTP interface using a reqwest client.

That all worked fine but I wanted a better story around authentication so I started migrating to ic-agent.

I'm almost done with that but ran into something at the very last step that is making me reconsider my approach to using ic-agent (not whether to use ic-agent at all, just my approach to using it)

My previous code relies on the fact that reqwest::blocking::Body::new takes a reader (R: Read + Send + 'static), and that I can configure a request by providing a reference to a reader that will get written to later.

For now I needed things to work in a blocking context, and it was easier to use the reqwest::blocking variant of things so I did that. I had planned to investigate switching to the async version at some point where the equivalent method appears to be reqwest::Body::wrap_stream

Since I at least know that the blocking version of reqwest allows providing a reader, and ic-agent also uses reqwest in ReqwestHttpReplicaV2Transport, I'm wondering if ic-agent could expose a similar interface.

Could agent::QueryBuilder::with_arg and agent::UpdateBuilder::with_arg be generalized to take readers instead?

If that isn't feasible, is there another approach that would enable async streaming of the request body and response?

@domwoe
Copy link
Member

domwoe commented Jan 13, 2023

@adamspofford-dfinity Any thoughts?

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