Skip to content

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

Closed

Description

@spring-projects-issues

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

Activity

  1. added
    type: enhancement
    in: web
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions