Skip to content

Introduce addSupportedMediaTypes() in FormHttpMessageConverter #23203

@sbrannen

Description

@sbrannen

Status Quo

Although it is currently possible to add a custom supported MediaType to FormHttpMessageConverter, it is a bit cumbersome since the List returned by getSupportedMediaTypes() is immutable, which leads to code similar to the following.

FormHttpMessageConverter converter = // ...
List<MediaType> supportedMediaTypes = new ArrayList<>(converter.getSupportedMediaTypes());
supportedMediaTypes.add(new MediaType("text", "custom-type"));
converter.setSupportedMediaTypes(supportedMediaTypes);

Proposal

It would be great if adding a custom media type was as simple as the following, where addSupportedMediaTypes() accepts a var-args list.

FormHttpMessageConverter converter = // ...
converter.addSupportedMediaTypes(new MediaType("text", "custom-type"));

Related Issues

Deliverables

  • Introduce addSupportedMediaTypes(MediaType...) in FormHttpMessageConverter.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions