-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
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.
spring-framework/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestHeader.java
Lines 63 to 71 in 0cbea29
* Whether the header is required. | |
* <p>Defaults to {@code true}, leading to an exception being thrown | |
* if the header is missing in the request. Switch this to | |
* {@code false} if you prefer a {@code null} value if the header is | |
* not present in the request. | |
* <p>Alternatively, provide a {@link #defaultValue}, which implicitly | |
* sets this flag to {@code false}. | |
*/ | |
boolean required() default true; |
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.