Skip to content

Provide support for adding to the mime types that are compressed#48930

Closed
jdsalasca wants to merge 3 commits intospring-projects:mainfrom
jdsalasca:add-compression-mime-types
Closed

Provide support for adding to the mime types that are compressed#48930
jdsalasca wants to merge 3 commits intospring-projects:mainfrom
jdsalasca:add-compression-mime-types

Conversation

@jdsalasca
Copy link
Contributor

@jdsalasca jdsalasca commented Jan 21, 2026

Summary

  • add server.compression.additional-mime-types so users can append types without replacing defaults
  • merge base and additional MIME types in Compression#getMimeTypes
  • add binding test coverage for the new property

Motivation

Fixes #48927. This keeps the default compressible MIME list intact while allowing extra types to be configured.

Testing

  • ./gradlew :module:spring-boot-web-server:test --tests "org.springframework.boot.web.server.autoconfigure.ServerPropertiesTests"

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 21, 2026
@jdsalasca jdsalasca force-pushed the add-compression-mime-types branch from c47dd46 to bd421b5 Compare January 21, 2026 21:48
Copy link
Member

@philwebb philwebb left a comment

Choose a reason for hiding this comment

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

Thanks! I've left some comments for your consideration.

*/
public String[] getMimeTypes() {
return this.mimeTypes;
if (this.additionalMimeTypes.length == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep the symmetric with setMimeTypes and move the the combined logic to a new method. Perhaps getAllMimeTypes()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I kept getMimeTypes() as the base list and added getAllMimeTypes() to return the combined list. Updated usages to call getAllMimeTypes() so the behavior remains symmetric

}
String[] combined = new String[this.mimeTypes.length + this.additionalMimeTypes.length];
System.arraycopy(this.mimeTypes, 0, combined, 0, this.mimeTypes.length);
System.arraycopy(this.additionalMimeTypes, 0, combined, this.mimeTypes.length, this.additionalMimeTypes.length);
Copy link
Member

Choose a reason for hiding this comment

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

You can use StringUtils.concatenateStringArrays(String[], String[]) (from org.springframework.util) to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call — now using StringUtils.concatenateStringArrays(...) with a null guard to satisfy NullAway

@jdsalasca
Copy link
Contributor Author

Hi! Thanks for the comments. I’ve updated the code to reflect your suggestions. Thanks again

@wilkinsona wilkinsona self-assigned this Jan 23, 2026
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 23, 2026
@wilkinsona wilkinsona added this to the 4.1.x milestone Jan 23, 2026
@wilkinsona wilkinsona changed the title Add additional compression mime types property Provide support for adding to the mime types that are compressed Jan 23, 2026
@wilkinsona wilkinsona modified the milestones: 4.1.x, 4.1.0-M2 Jan 23, 2026
wilkinsona pushed a commit that referenced this pull request Jan 23, 2026
@wilkinsona
Copy link
Member

Thanks very much, @jdsalasca.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide support for adding to the mime types that are compressed

4 participants