Affects: 6.0.0-RC2
Given the following Controller:
record RequestData(String msg){};
@RestController
public class SampleController {
@PostMapping(value = "/", consumes = "application/vnd.demo-v1.0+json;charset=utf-8")
public String sample(@RequestBody RequestData data) {
return "Success " + data.msg();
}
}
When accessing this endpoint via curl I get different behaviours for the following requests:
Success: (when using lower case utf-8)
$ curl -v localhost:8080 -H "Content-type: application/vnd.demo-v1.0+json;charset=utf-8" -d '{"msg": "hello"}'
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.84.0
> Accept: */*
> Content-type: application/vnd.demo-v1.0+json;charset=utf-8
> Content-Length: 16
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200
< Content-Type: text/plain;charset=UTF-8
< Content-Length: 13
< Date: Wed, 02 Nov 2022 09:19:15 GMT
<
Success hello* Connection #0 to host localhost left intact
Failure: (when using upper case UTF-8)
$ curl -v localhost:8080 -H "Content-type: application/vnd.demo-v1.0+json;charset=UTF-8" -d '{"msg": "hello"}'
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.84.0
> Accept: */*
> Content-type: application/vnd.demo-v1.0+json;charset=UTF-8
> Content-Length: 16
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 415
< Accept: application/vnd.demo-v1.0+json;charset=utf-8
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Wed, 02 Nov 2022 09:18:57 GMT
<
{"timestamp":"2022-11-02T09:18:57.530+00:00","status":415,"error":"Unsupported Media Type","path":"/"}* Connection #0 to host localhost left intact
This behavior is new with the 6.0 stream. With 5.3 both requests delivered a 200 response.
Comment From: poutsma
I think this is due to the fix for #28024.
@rstoyanchev Thoughts? Should we do a case insensitive comparison instead?
Comment From: rstoyanchev
Yes, I think that would make sense.
Comment From: poutsma
Looks like we used equalsIgnoreCase
before this was refactored because of #28024, see https://github.com/spring-projects/spring-framework/blob/259bcd60fbbc5cdb8b230595a5004707f4c6ff23/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java#L369.