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

wasm support #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

wasm support #10

wants to merge 2 commits into from

Conversation

wooden-worm
Copy link

This changes ResponseExt and OneDrive::new() to support wasm32. Also avoids boxing in ResponseExt

Comment on lines +65 to +72
#[cfg(not(target_arch = "wasm32"))]
let client = Client::builder()
.redirect(reqwest::redirect::Policy::none())
.gzip(true)
.build()
.unwrap();
#[cfg(target_arch = "wasm32")]
let client = Client::builder().build().unwrap();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Do you mean gzip or redirect is unsupported on wasm32?

redirect must not be disabled because get_item_download_url requires it to correctly function. The documentation of new_with_client already mentioned this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep reqwest does not have redirect or gzip for wasm32 target.

I propose for wasm we:

  • Disable get_item_download_url
  • Add get_item_content, which follows redirects and return a Vec<u8>

What do you think?

Copy link
Owner

@oxalica oxalica May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep reqwest does not have redirect or gzip for wasm32 target.

Are there target-related difficulties about implementing them? Or is it just reqwest have not yet implemented them? It seems ClientBuilder on wasm32 is pretty incomplete (there are even placeholder documentations) and have only few methods available.

  • Disable get_item_download_url
  • Add get_item_content, which follows redirects and return a Vec<u8>

I'm not a fan of providing different (and inconsistent) APIs on different targets.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

  • For get_item_download_url, add a cfg_if to panic on wasm with something like not supported, please use get_item_content
  • Implement get_item_content for all platforms

I also don't quite get get_item_download_url. What benefits does it have over simply following redirects and provide get_item_content directly?

src/util.rs Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

2 participants