Do not use Servlet 3.0 API in doOptions()
Refactor FrameworkServlet.doOptions() to capture the "Allow" header by using a HttpServletResponseWrapper. Prior to this commit the HttpServletResponse.getHeader() method was used which is only available in Servlet 3.0 environments. Issue: SPR-10341
This commit is contained in:
@@ -61,6 +61,8 @@ import org.springframework.web.util.WebUtils;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
@@ -857,9 +859,10 @@ public class DispatcherServletTests extends TestCase {
|
||||
|
||||
public void testAllowedOptionsIncludesPatchMethod() throws Exception {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "OPTIONS", "/foo");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
MockHttpServletResponse response = spy(new MockHttpServletResponse());
|
||||
DispatcherServlet servlet = new DispatcherServlet();
|
||||
servlet.service(request, response);
|
||||
verify(response, never()).getHeader(anyString()); // SPR-10341
|
||||
assertThat(response.getHeader("Allow"), equalTo("GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user