List OPTIONS in OPTIONS responses for @RequestMapping
Issue: SPR-16513
This commit is contained in:
parent
f7d60b7f58
commit
6cf6d8834c
|
@ -365,6 +365,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
|||
if (result.contains(HttpMethod.GET)) {
|
||||
result.add(HttpMethod.HEAD);
|
||||
}
|
||||
result.add(HttpMethod.OPTIONS);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,8 +195,8 @@ public class RequestMappingInfoHandlerMappingTests {
|
|||
List<HttpMethod> allMethodExceptTrace = new ArrayList<>(Arrays.asList(HttpMethod.values()));
|
||||
allMethodExceptTrace.remove(HttpMethod.TRACE);
|
||||
|
||||
testHttpOptions("/foo", EnumSet.of(HttpMethod.GET, HttpMethod.HEAD));
|
||||
testHttpOptions("/person/1", EnumSet.of(HttpMethod.PUT));
|
||||
testHttpOptions("/foo", EnumSet.of(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS));
|
||||
testHttpOptions("/person/1", EnumSet.of(HttpMethod.PUT, HttpMethod.OPTIONS));
|
||||
testHttpOptions("/persons", EnumSet.copyOf(allMethodExceptTrace));
|
||||
testHttpOptions("/something", EnumSet.of(HttpMethod.PUT, HttpMethod.POST));
|
||||
}
|
||||
|
|
|
@ -443,6 +443,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe
|
|||
result.add(HttpMethod.HEAD);
|
||||
}
|
||||
}
|
||||
result.add(HttpMethod.OPTIONS);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -172,8 +172,8 @@ public class RequestMappingInfoHandlerMappingTests {
|
|||
|
||||
@Test
|
||||
public void getHandlerHttpOptions() throws Exception {
|
||||
testHttpOptions("/foo", "GET,HEAD");
|
||||
testHttpOptions("/person/1", "PUT");
|
||||
testHttpOptions("/foo", "GET,HEAD,OPTIONS");
|
||||
testHttpOptions("/person/1", "PUT,OPTIONS");
|
||||
testHttpOptions("/persons", "GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS");
|
||||
testHttpOptions("/something", "PUT,POST");
|
||||
}
|
||||
|
|
|
@ -1776,7 +1776,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
|||
getServlet().service(request, response);
|
||||
|
||||
assertEquals(200, response.getStatus());
|
||||
assertEquals("GET,HEAD", response.getHeader("Allow"));
|
||||
assertEquals("GET,HEAD,OPTIONS", response.getHeader("Allow"));
|
||||
assertTrue(response.getContentAsByteArray().length == 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue