Support headers in DataBinding via constructor args

Closes gh-34073
This commit is contained in:
rstoyanchev
2024-12-11 15:10:09 +00:00
parent 7b4e19c69b
commit 70c326ed30
4 changed files with 77 additions and 3 deletions

View File

@@ -156,6 +156,9 @@ public class ExtendedServletRequestDataBinder extends ServletRequestDataBinder {
if (uriVars != null) {
value = uriVars.get(name);
}
if (value == null && getRequest() instanceof HttpServletRequest httpServletRequest) {
value = getHeaderValue(httpServletRequest, name);
}
}
return value;
}
@@ -167,6 +170,13 @@ public class ExtendedServletRequestDataBinder extends ServletRequestDataBinder {
if (uriVars != null) {
set.addAll(uriVars.keySet());
}
if (request instanceof HttpServletRequest httpServletRequest) {
Enumeration<String> enumeration = httpServletRequest.getHeaderNames();
while (enumeration.hasMoreElements()) {
String headerName = enumeration.nextElement();
set.add(headerName.replaceAll("-", ""));
}
}
return set;
}
}