Open
Description
Expected Behavior
The method defined here:
package com.example;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller
public class MyController {
@Get("/notModified")
public HttpResponse<String> notModified() {
return HttpResponse.notModified();
}
}
while a bit nonsensical, should work and cause the browser to receive a HTTP 304 response.
Actual Behaviour
The following page is returned instead:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404 Not Found</h2>
<table>
<tr><th>URI:</th><td>/notModified</td></tr>
<tr><th>STATUS:</th><td>404</td></tr>
<tr><th>MESSAGE:</th><td>Not Found</td></tr>
<tr><th>SERVLET:</th><td>-</td></tr>
</table>
<hr/><a href="[https://eclipse.org/jetty](view-source:https://eclipse.org/jetty)">Powered by Jetty:// 9.4.48.v20220622</a><hr/>
</body>
</html>
and if it helps any, these headers:
HTTP/1.1 404 Not Found
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html;charset=iso-8859-1
Content-Length: 455
Server: Jetty(9.4.48.v20220622)
Steps To Reproduce
- Create a new project by going to https://micronaut.io/launch and choosing all the default settings, but adding the
aws-lambda
feature. (default settings include Micronaut 3.7.1 and JDK 11) - Copy the controller described in Expected Behavior and delete the HomeController if you have it.
- Start the server using the
run
Gradle target. - Open http://localhost:8080/notModified in the browser.
Other observations
Broken
return HttpResponse.notModified();
return HttpResponse.notModified().body(null);
return HttpResponse.notModified().body(""); // empty string
Works, but invalid
return HttpResponse.notModified().body(" "); // single space
Environment Information
Zorin OS (Ubuntu 20.04 LTS)
JVM:
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
Example Application
No response
Version
3.7.1, 3.7.2-SNAPSHOT