Skip to content

Favor query parameters for content negotiation in WebFlux [SPR-15639] #20198

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

Closed
spring-projects-issues opened this issue Jun 7, 2017 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 7, 2017

Rossen Stoyanchev opened SPR-15639 and commented

Status Quo

Spring MVC supports suffix pattern matching for mapping requests to controllers along with a content negotiation strategy that can derive the content-type for the response from a file extension in the URI path.

Suffix pattern matching [can cause ambiguity|SPR-6164] when used in combination with URI variables unless applications limit suffix pattern matching to a list of explicitly registered file extension. When it is impractical to register supported extensions explicitly, it is hard to distinguish a file extension from a regular dot in the path since the list of possible file extensions is incredibly long (in the thousands depending on the source used).

File extensions can also be difficult to extract and use consistently when path parameters (matrix variables) are present, in addition to path decoding and other issues that can be further complicated or hard to reason about through the use of configuration options. Such flexibility can also lead to security issues (see Suffix Pattern Matching and RFD).

WebFlux

The above are sufficient reason for WebFlux to not support suffix pattern matching and to (through default configuration) favor the use of a query parameter for URI-based content negotiation instead. This means out of the box, the presence of a file extension in the path of a URL will have no special meaning for request mapping and no impact on content negotiation. The only exception is where a file extension is naturally present in a URL such as a static resource URL for which ResourceWebHandler will use the MediaTypeFactory to look up the content type for the matched file system resource.

Spring MVC

The goal of this ticket is also to ensure that applications can achieve the same effect on the Spring MVC side by turning off suffix pattern matching and using query parameter based content negotiation including lookups through the MediaTypeFactory (currently not supported).


Sub-tasks:

Issue Links:

Referenced from: commits b0e8e7f, 01a9251, b65bfdb, cb60473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants