From beb9a5f45f5f2fc84fa2ddba20be4be7fd47b901 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 5 Jun 2025 14:17:46 +0000 Subject: fix(response): Always proxy images as raw bytes --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/response.rs | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c4bc5c..0ea4cfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -856,9 +856,9 @@ dependencies = [ [[package]] name = "germ" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb35c4432f7fdc139b68689e8a0741d118392566f8c63ca725971acaaa4b2ea" +checksum = "603354f11eb56ae667d4f1ec32162b90a01c8c40c70195f5386f2fc65e5aa272" dependencies = [ "anyhow", "rustls", diff --git a/Cargo.toml b/Cargo.toml index 12d81fd..7713a9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ opt-level = 3 [dependencies] # Gemini -germ = { version = "0.4.6", features = ["ast", "meta"] } +germ = { version = "0.4.7", features = ["ast", "meta"] } # HTTP actix-web = "4.11.0" diff --git a/src/response.rs b/src/response.rs index 75fdb3b..1a68b08 100644 --- a/src/response.rs +++ b/src/response.rs @@ -93,6 +93,16 @@ pub async fn default( timer = Instant::now(); + if response.meta().starts_with("image/") { + if let Some(content_bytes) = &response.content_bytes() { + return Ok( + HttpResponse::build(actix_web::http::StatusCode::OK) + .content_type(response.meta().as_ref()) + .body(content_bytes.to_vec()), + ); + } + } + let mut html_context = if configuration.is_raw() { String::new() } else { -- cgit v1.2.3