diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index bc34fcd77..0215d8e87 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -6,6 +6,7 @@ - Improve handling of non-UTF-8 header values in `Logger` middleware. - Add `HttpServer::shutdown_signal()` method. - Mark `HttpServer` as `#[must_use]`. +- Allow SVG images to be compressed by the `Compress` middleware. - Ignore `Host` header in `Host` guard when connection protocol is HTTP/2. - Re-export `mime` dependency. - Update `brotli` dependency to `8`. diff --git a/actix-web/src/middleware/compress.rs b/actix-web/src/middleware/compress.rs index 943868d21..7f0d8a4fb 100644 --- a/actix-web/src/middleware/compress.rs +++ b/actix-web/src/middleware/compress.rs @@ -191,8 +191,10 @@ where None => true, Some(hdr) => { match hdr.to_str().ok().and_then(|hdr| hdr.parse::().ok()) { - Some(mime) if mime.type_().as_str() == "image" => false, - Some(mime) if mime.type_().as_str() == "video" => false, + Some(mime) if mime.type_() == mime::IMAGE => { + matches!(mime.subtype(), mime::SVG) + } + Some(mime) if mime.type_() == mime::VIDEO => false, _ => true, } }