mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Fix filtered HTTP headers in data binding
Prior to this commit, several common HTTP headers were ignored from the data binding process when collecting property values, in gh-34039 and gh-34182. This commit completes the initial enhancement by ensuring that the default header predicate is also considering cases where constructor binding is applied and the Java type has a lowercase variant of the HTTP header name to filter. Fixes gh-34292
This commit is contained in:
+25
-1
@@ -27,6 +27,7 @@ import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.ServletRequestDataBinder;
|
||||
import org.springframework.web.bind.annotation.BindParam;
|
||||
import org.springframework.web.bind.support.BindParamNameResolver;
|
||||
@@ -36,7 +37,7 @@ import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link ExtendedServletRequestDataBinder}.
|
||||
* Tests for {@link ExtendedServletRequestDataBinder}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@@ -136,6 +137,19 @@ class ExtendedServletRequestDataBinderTests {
|
||||
assertThat(bean.someIntArray()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void filteredPriorityHeaderForConstructorBinding() {
|
||||
TestBinder binder = new TestBinder();
|
||||
binder.setTargetType(ResolvableType.forClass(TestTarget.class));
|
||||
request.addHeader("Priority", "u1");
|
||||
|
||||
binder.construct(request);
|
||||
BindingResult result = binder.getBindingResult();
|
||||
TestTarget target = (TestTarget) result.getTarget();
|
||||
|
||||
assertThat(target.priority).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void headerPredicate() {
|
||||
TestBinder binder = new TestBinder();
|
||||
@@ -179,4 +193,14 @@ class ExtendedServletRequestDataBinderTests {
|
||||
}
|
||||
}
|
||||
|
||||
static class TestTarget {
|
||||
|
||||
final String priority;
|
||||
|
||||
public TestTarget(String priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user