Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
7 vraptor-core/src/main/java/br/com/caelum/vraptor/Options.java
@@ -32,5 +32,12 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Options {
+
+ /**
+ * All paths that will be mapped to an annotated Resource method.
+ * @return
+ */
+ String[] value() default {};
+
}
View
4 ...tor-core/src/main/java/br/com/caelum/vraptor/resource/DefaultMethodNotAllowedHandler.java
@@ -38,7 +38,9 @@ public void deny(RequestInfo request, Set<HttpMethod> allowedMethods) {
request.getResponse().addHeader(
"Allow", allowedMethods.toString().replaceAll("\\[|\\]", ""));
try {
- request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ if (!"OPTIONS".equalsIgnoreCase(request.getRequest().getMethod())) {
+ request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ }
} catch (IOException e) {
throw new InterceptionException(e);
}
View
3 ...r-core/src/test/java/br/com/caelum/vraptor/http/route/PathAnnotationRoutesParserTest.java
@@ -330,8 +330,7 @@ public void remove() {
public void head() {
}
- @Path("/clients/options")
- @Options
+ @Options("/clients/options")
public void options() {
}
View
7 ...core/src/test/java/br/com/caelum/vraptor/resource/DefaultMethodNotAllowedHandlerTest.java
@@ -3,6 +3,7 @@
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -50,12 +51,12 @@ public void shouldSendErrorMethodNotAllowed() throws Exception {
}
@Test
- public void shouldSendMethodNotAllowedIfTheRequestMethodIsOptions() throws Exception {
+ public void shouldNotSendMethodNotAllowedIfTheRequestMethodIsOptions() throws Exception {
when(mockRequest.getMethod()).thenReturn("OPTIONS");
- this.handler.deny(request, EnumSet.of(HttpMethod.OPTIONS));
+ this.handler.deny(request, EnumSet.of(HttpMethod.GET, HttpMethod.POST));
- verify(response).sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+ verify(response, never()).sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}
@Test(expected=InterceptionException.class)

No commit comments for this range

Something went wrong with that request. Please try again.