From bdec2b9ce266c216949e0b697899f726041ef3a3 Mon Sep 17 00:00:00 2001 From: jf908 Date: Mon, 30 Jun 2025 19:09:55 +0100 Subject: [PATCH] Add release notes and ureq feature docs --- crates/bevy_asset/src/http_source.rs | 9 +++++++++ release-content/release-notes/http_source.md | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 release-content/release-notes/http_source.md diff --git a/crates/bevy_asset/src/http_source.rs b/crates/bevy_asset/src/http_source.rs index c92652acc7..a17bcf9af5 100644 --- a/crates/bevy_asset/src/http_source.rs +++ b/crates/bevy_asset/src/http_source.rs @@ -10,6 +10,15 @@ use std::path::{Path, PathBuf}; /// /// Any asset path that begins with `http` (when the `http` feature is enabled) or `https` (when the /// `https` feature is enabled) will be loaded from the web via `fetch`(wasm) or `ureq`(native). +/// +/// By default, `ureq`'s HTTP compression is disabled. To enable gzip and brotli decompression, add +/// the following dependency and features to your Cargo.toml. This will improve bandwidth +/// utilization when its supported by the server. +/// +/// ```toml +/// [target.'cfg(not(target_family = "wasm"))'.dev-dependencies] +/// ureq = { version = "3", default-features = false, features = ["gzip", "brotli"] } +/// ``` pub struct HttpSourcePlugin; impl Plugin for HttpSourcePlugin { diff --git a/release-content/release-notes/http_source.md b/release-content/release-notes/http_source.md new file mode 100644 index 0000000000..faed8fae19 --- /dev/null +++ b/release-content/release-notes/http_source.md @@ -0,0 +1,19 @@ +--- +title: HTTP Assets +authors: ["@johanhelsing", "@mrchantey", "@jf908"] +pull_requests: [17889] +--- + +Bevy now supports downloading assets over http and https. +Use the new `http` and `https` features to enable `http://` and `https://` URLs as asset paths. +This functionality is powered by the [`ureq`](https://github.com/algesten/ureq) crate on native platforms and the fetch API on wasm. + +```rust +let image = asset_server.load("https://example.com/image.png"); +commands.spawn(Sprite::from_image(image)); +``` + +By default these assets aren’t saved anywhere but you can enable the `http_source` feature to cache assets on your file system. + +The implementation has changed quite a bit but this feature originally started out as an upstreaming of the [`bevy_web_asset`](https://github.com/johanhelsing/bevy_web_asset) crate. +Special thanks to @johanhelsing and bevy_web_asset's contributors!