Explicit HEAD sorted higher than implicit GET match
Issue: SPR-14182
This commit is contained in:
@@ -53,7 +53,7 @@ public class RequestMethodsRequestConditionTests {
|
||||
@Test
|
||||
public void getMatchingConditionWithHttpHead() {
|
||||
testMatch(new RequestMethodsRequestCondition(HEAD), HEAD);
|
||||
testMatch(new RequestMethodsRequestCondition(GET), HEAD);
|
||||
testMatch(new RequestMethodsRequestCondition(GET), GET);
|
||||
testNoMatch(new RequestMethodsRequestCondition(POST), HEAD);
|
||||
}
|
||||
|
||||
|
||||
@@ -1776,6 +1776,18 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
||||
assertEquals("body", response.getContentAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void httpHeadExplicit() throws ServletException, IOException {
|
||||
initServletWithControllers(ResponseEntityController.class);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("HEAD", "/stores");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
getServlet().service(request, response);
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
assertEquals("v1", response.getHeader("h1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void httpOptions() throws ServletException, IOException {
|
||||
initServletWithControllers(ResponseEntityController.class);
|
||||
@@ -3100,6 +3112,16 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
||||
public ResponseEntity<String> baz() {
|
||||
return ResponseEntity.ok().header("MyResponseHeader", "MyValue").body("body");
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/stores", method = RequestMethod.HEAD)
|
||||
public ResponseEntity<Void> headResource() {
|
||||
return ResponseEntity.ok().header("h1", "v1").build();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/stores", method = RequestMethod.GET)
|
||||
public ResponseEntity<String> getResource() {
|
||||
return ResponseEntity.ok().body("body");
|
||||
}
|
||||
}
|
||||
|
||||
@Controller
|
||||
|
||||
Reference in New Issue
Block a user