Hello
When I read the below comments I understand that if a header is blank it is treated as missing regardless of thinking of the Key-Value concept.
For example, when we request a string header, even it is a blank string the controller does not respond as a bad request.
if the header is missing in the request
, maybe I am assuming for this condition that a blank string does not mean missing header?
I wish we could somehow mention that regardless of the value it checks only the presence of the key of the header.
https://github.com/spring-projects/spring-framework/blob/0cbea295178543d515bc4ce80ec152a1f8ddb2bc/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestHeader.java#L63-L71
Disclosure: I am aware of Spring 5.3+, for type conversions it works very well, but in my case is without type conversion. i.e. requesting string header and no type conversion.
Comment From: rstoyanchev
The header is indeed considered present but without a value. In the case where type conversion is required, it can "hide" the original empty value, and hence the change in 5.3 with #23939. We could improve the Javadoc for this.
Comment From: rstoyanchev
As to the question, why empty is not treated as missing, it really depends on your use case and perspective. There have been many discussions on the subject, and changing behavior will only lead to regressions for others.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.