Make OPTIONS/TRACE request handling configurable

Add properties to WebMvcProperties allowing control of if TRACE/OPTIONS
requests should go through the regular dispatching chain.

Closes gh-4300
This commit is contained in:
Bohuslav Burghardt
2015-10-26 10:03:32 +01:00
committed by Phillip Webb
parent a8b23f9deb
commit 88cf65427f
4 changed files with 42 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -155,10 +155,18 @@ public class DispatcherServletAutoConfigurationTests {
DispatcherServletAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mvc.throw-exception-if-no-handler-found:true");
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mvc.dispatch-options-request:true");
EnvironmentTestUtils.addEnvironment(this.context,
"spring.mvc.dispatch-trace-request:true");
this.context.refresh();
DispatcherServlet bean = this.context.getBean(DispatcherServlet.class);
assertEquals(true, new DirectFieldAccessor(bean)
.getPropertyValue("throwExceptionIfNoHandlerFound"));
assertEquals(true,
new DirectFieldAccessor(bean).getPropertyValue("dispatchOptionsRequest"));
assertEquals(true,
new DirectFieldAccessor(bean).getPropertyValue("dispatchTraceRequest"));
}
@Configuration