Current Behavior
POST and GET endpoint work with different encoding characters for HTTP headers.
While sending a header with Spanish word "muñoz" to a GET controller, it works as expected. But when sending the same header to a POST controller, the character encoding fails binding the String as "muñoz".
Expected Behavior
For me both cases (GET and POST) should use the same character encoding
Minimal yet complete reproducer code(or URL to code)
https://github.com/egosumcarlos/demo-spring-headers-specials-chars-in-post/blob/master/src/main/java/com/example/demo/DemoController.java
Hit the controllers with:
curl --location --request GET 'http://localhost:8080/dummy' --header 'cust-full-name: muñoz'
curl --location --request POST 'http://localhost:8080/dummy' \
--header 'cust-full-name: muñoz' \
--header 'Content-Type: application/json' \
--data-raw '{
"dni":"321"
}'
Comment From: wilkinsona
Thanks for the sample. Unfortunately, it doesn't appear to reproduce the behavior that you have described with both GET and POST receiving the header as muñoz:
2022-07-20 11:16:03.021 INFO 27131 --- [ctor-http-nio-2] com.example.demo.DemoController : header from GET muñoz
2022-07-20 11:16:30.507 INFO 27131 --- [ctor-http-nio-3] com.example.demo.DemoController : dto 321
2022-07-20 11:16:30.507 INFO 27131 --- [ctor-http-nio-3] com.example.demo.DemoController : header from POST muñoz
This is the behavior that I would expect as only US-ASCII is permitted in HTTP headers.