Skip to content

Commit 13c9810

Browse files
authored
Merge pull request #597 from jooby-project/596
unhandled requests must returns a 404 not 415 fix #596
2 parents 6ffa831 + 7ab9c18 commit 13c9810

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
@@ -503,7 +503,9 @@ private static Err handle406or415(final Set<Route.Definition> routeDefs, final S
503503
.map(MediaType::name)
504504
.collect(Collectors.joining(", ")));
505505
}
506-
return new Err(Status.UNSUPPORTED_MEDIA_TYPE, contentType.name());
506+
if (!contentType.isAny()) {
507+
return new Err(Status.UNSUPPORTED_MEDIA_TYPE, contentType.name());
508+
}
507509
}
508510
}
509511
return null;

0 commit comments

Comments
 (0)