Skip to content

Commit 7ab9c18

Browse files
committed
unhandled requests must returns a 404 not 415 fix #596
1 parent fcf568b commit 7ab9c18

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.jooby.issues;
2+
3+
import org.jooby.test.ServerFeature;
4+
import org.junit.Test;
5+
6+
public class Issue596 extends ServerFeature {
7+
8+
{
9+
get("/596", (req, rsp) -> {
10+
11+
});
12+
}
13+
14+
@Test
15+
public void shouldGet404onUnhandledRequests() throws Exception {
16+
request()
17+
.get("/596")
18+
.expect(404);
19+
}
20+
}

jooby/src/main/java/org/jooby/Status.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
* HTTP status codes.
2323
*
2424
* <p>
25-
* This code has been kindly borrowed from <a href="http://spring.io/">Spring</a>
25+
* This code has been kindly borrowed from <a href="http://spring.io/">Spring</a>.
2626
* </p>
27-
* .
2827
*
2928
* @author Arjen Poutsma
3029
* @see <a href="http://www.iana.org/assignments/http-status-codes">HTTP Status Code Registry</a>

jooby/src/main/java/org/jooby/internal/HttpHandlerImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,9 @@ private static Err handle406or415(final Set<Route.Definition> routeDefs, final S
497497
.map(MediaType::name)
498498
.collect(Collectors.joining(", ")));
499499
}
500-
return new Err(Status.UNSUPPORTED_MEDIA_TYPE, contentType.name());
500+
if (!contentType.isAny()) {
501+
return new Err(Status.UNSUPPORTED_MEDIA_TYPE, contentType.name());
502+
}
501503
}
502504
}
503505
return null;

0 commit comments

Comments
 (0)