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

Compress middleware should not compress image/* content types #2981

Closed
nyurik opened this issue Feb 18, 2023 · 2 comments · Fixed by #3075 · May be fixed by #2996
Closed

Compress middleware should not compress image/* content types #2981

nyurik opened this issue Feb 18, 2023 · 2 comments · Fixed by #3075 · May be fixed by #2996
Assignees
Labels
A-web project: actix-web C-improvement Category: an improvement to existing functionality good-first-issue easy to pick up for newcomers

Comments

@nyurik
Copy link

nyurik commented Feb 18, 2023

Expected Behavior

Most image/* mime types such as png and jpeg are already pre-compressed, so when using .wrap(middleware::Compress::default()), the expectation is that the well known images would not be compressed.

Current Behavior

Currently the compression middleware only looks at the content-encoding of the response (which should not be set for images), and thus compresses images again.

Possible Solution

  • Check against a list of well known image types
  • Offer a way to set a callback so that the user can check themselves
  • all of the above?

Your Environment

  • Rust Version: 1.67.1
  • Actix Web Version: 4.3.0
@robjtede
Copy link
Member

I am surprised that browsers send Accept-Encoding headers for image assets so this appears to be a legitimate issue.

@robjtede robjtede added C-improvement Category: an improvement to existing functionality A-web project: actix-web good-first-issue easy to pick up for newcomers labels Feb 21, 2023
@cptrodolfox
Copy link
Contributor

Hey @robjtede , I am interested in working on this issue. I will start working on a solution. I might have some questions though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web C-improvement Category: an improvement to existing functionality good-first-issue easy to pick up for newcomers
Projects
None yet
3 participants