Skip to content

Commit 399156b

Browse files
authored
Merge pull request #87 from prime-framework/degroff/update_for_501
Update to handle `501` again when the HTTP verb is not handled by prime-mvc
2 parents 86e44bc + 957306c commit 399156b

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.primeframework</groupId>
77
<artifactId>prime-mvc</artifactId>
8-
<version>5.1.1</version>
8+
<version>5.2.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>FusionAuth App</name>

src/main/java/org/primeframework/mvc/action/DefaultActionMappingWorkflow.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001-2024, Inversoft Inc., All Rights Reserved
2+
* Copyright (c) 2001-2025, Inversoft Inc., All Rights Reserved
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import io.fusionauth.http.server.HTTPRequest;
2828
import io.fusionauth.http.server.HTTPResponse;
2929
import org.primeframework.mvc.NotAllowedException;
30+
import org.primeframework.mvc.NotImplementedException;
3031
import org.primeframework.mvc.http.HTTPTools;
3132
import org.primeframework.mvc.http.Status;
3233
import org.primeframework.mvc.parameter.fileupload.annotation.FileUpload;
@@ -93,7 +94,15 @@ public void perform(WorkflowChain chain) throws IOException {
9394
if (actionInvocation.action != null && actionInvocation.method == null) {
9495
Class<?> actionClass = actionInvocation.configuration.actionClass;
9596
logger.debug("The action class [{}] does not have a valid execute method for the HTTP method [{}]", actionClass.getCanonicalName(), method);
96-
throw new NotAllowedException();
97+
98+
// Differentiate between not allowed for this action, vs not-implemented (supported by prime-mvc).
99+
if (HTTPMethod.StandardMethods.containsKey(method.name())) {
100+
throw new NotAllowedException();
101+
}
102+
103+
// Note that the DefaultActionConfigurationBuilder will only resolve executeMethods for methods named in StandardMethods.
104+
// See HTTPMethod.StandardMethods and DefaultActionConfigurationBuilder.findExecuteMethods
105+
throw new NotImplementedException();
97106
}
98107

99108
// Handle multipart file configuration

src/test/java/org/primeframework/mvc/GlobalTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,11 @@ public void notAllowed() {
14651465
public void notImplemented() {
14661466
simulator.test("/not-allowed")
14671467
.method("POTATO")
1468-
.assertStatusCode(405) // Not allowed since we can handle any name but the action doesn't have that method
1468+
// We currently only map out execute methods in the action that are named by a method
1469+
// defined in the HTTPMethod.StandardMethods. If an action does not define a standard HTTP
1470+
// method, a 405 will be returned. If you ask for a non-standard method that is not implemented
1471+
// by prime-mvc, you will receive a 501.
1472+
.assertStatusCode(501)
14691473
.assertHeaderContains("Cache-Control", "no-cache");
14701474
}
14711475

0 commit comments

Comments
 (0)