mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(lambda-web): write the day with two digits in the date header of the platform pages (#7172)
* fix(lambda-web): write the day with two digits in the date header of the platform pages The platform pages and the 414 write the day of their date header with two digits on AWS, as in Sun, 01 Nov 2026. RFC_1123_DATE_TIME writes 1. * refactor(lambda-web): write the Date header of the metadata server with platformDate
This commit is contained in:
1 parent
e6b1f54cb4
commit
c8dec86997
5 files changed
+19
-12
No files matched your search
@@ -103,6 +103,8 @@ The platform answers these cases itself, with the AWS HTML pages and `lambda-web
|
||||
| 504 | `Runtime.RequestTimeout` | No response within the revision's `timeoutSeconds` |
|
||||
| 505 | `Platform.UnsupportedHttpVersion` | HTTP/1.0 |
|
||||
|
||||
The `date` header of these pages writes the day with two digits, as on AWS: `Sun, 01 Nov 2026 02:33:33 GMT`. The `400` and `431` pages write a two-digit year as well: `Sun, 01 Nov 26 02:33:34 GMT`.
|
||||
|
||||
A URI of 65,535 bytes or more gets an empty `414`, as on AWS. Headers or a request line past 256 KiB get the HTTP server's empty `431` or `414` instead of the AWS answer. A request without a `Host` header cannot be told apart from one for another Floci service, so it does not get `Platform.MissingHostHeader`.
|
||||
|
||||
## Logs
|
||||
|
||||
@@ -33,8 +33,6 @@ import org.jboss.logging.Logger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -67,7 +65,6 @@ public class LambdaWebDataPlane {
|
||||
private static final Logger LOG = Logger.getLogger(LambdaWebDataPlane.class);
|
||||
private static final String BASE32 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
private static final int REQUEST_ID_LENGTH = 26;
|
||||
private static final DateTimeFormatter HTTP_DATE = DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneOffset.UTC);
|
||||
/** Floci sees an exit some tens of milliseconds after it. A process that keeps running is not waited for longer. */
|
||||
private static final Duration EXIT_WAIT = Duration.ofSeconds(1);
|
||||
/** The edge counts the request line, the header lines and the blank line, as the client sent them. */
|
||||
@@ -637,7 +634,7 @@ public class LambdaWebDataPlane {
|
||||
if (page.errorType() != null) {
|
||||
response.headers().set("lambda-web-error-type", page.errorType());
|
||||
}
|
||||
response.headers().set("date", HTTP_DATE.format(Instant.now()));
|
||||
response.headers().set("date", LambdaWebErrorPages.platformDate(Instant.now()));
|
||||
String html = LambdaWebErrorPages.html(page, requestId);
|
||||
// A HEAD request gets the length of the page it does not get, as on AWS.
|
||||
response.headers().set("content-length", String.valueOf(html.getBytes(StandardCharsets.UTF_8).length));
|
||||
@@ -672,7 +669,7 @@ public class LambdaWebDataPlane {
|
||||
response.setStatusCode(414).setStatusMessage("URI Too Long");
|
||||
response.headers().set("connection", "close");
|
||||
response.headers().set("content-length", "0");
|
||||
response.headers().set("date", HTTP_DATE.format(Instant.now()));
|
||||
response.headers().set("date", LambdaWebErrorPages.platformDate(Instant.now()));
|
||||
response.end().onComplete(ignored -> response.close());
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,9 @@ final class LambdaWebErrorPages {
|
||||
/** The edge writes a two-digit year in its Date header. */
|
||||
private static final DateTimeFormatter EDGE_DATE =
|
||||
DateTimeFormatter.ofPattern("EEE, dd MMM yy HH:mm:ss 'GMT'", Locale.ROOT).withZone(ZoneOffset.UTC);
|
||||
/** The platform writes a two-digit day, which RFC_1123_DATE_TIME leaves out. */
|
||||
private static final DateTimeFormatter PLATFORM_DATE =
|
||||
DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ROOT).withZone(ZoneOffset.UTC);
|
||||
|
||||
private LambdaWebErrorPages() {
|
||||
}
|
||||
@@ -70,4 +73,8 @@ final class LambdaWebErrorPages {
|
||||
static String edgeDate(Instant now) {
|
||||
return EDGE_DATE.format(now);
|
||||
}
|
||||
|
||||
static String platformDate(Instant now) {
|
||||
return PLATFORM_DATE.format(now);
|
||||
}
|
||||
}
|
||||
+2
-7
@@ -20,10 +20,7 @@ import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -47,8 +44,6 @@ public class LambdaWebMetadataServer {
|
||||
private static final String UNAUTHORIZED = "\"Client.Unauthorized\"\n";
|
||||
private static final String NOT_FOUND = "404 page not found\n";
|
||||
private static final String NO_HOST = "Bad Request: missing required Host header";
|
||||
private static final DateTimeFormatter HTTP_DATE =
|
||||
DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ROOT).withZone(ZoneOffset.UTC);
|
||||
private static final Logger LOG = Logger.getLogger(LambdaWebMetadataServer.class);
|
||||
|
||||
private final Vertx vertx;
|
||||
@@ -170,7 +165,7 @@ public class LambdaWebMetadataServer {
|
||||
if (method == HttpMethod.GET || method == HttpMethod.HEAD) {
|
||||
response.putHeader("Content-Type", HTML);
|
||||
}
|
||||
response.putHeader("Location", location).putHeader("Date", HTTP_DATE.format(Instant.now()));
|
||||
response.putHeader("Location", location).putHeader("Date", LambdaWebErrorPages.platformDate(Instant.now()));
|
||||
if (method == HttpMethod.GET) {
|
||||
end(response, "<a href=\"" + htmlEscape(location) + "\">Temporary Redirect</a>.\n\n");
|
||||
} else if (method == HttpMethod.HEAD) {
|
||||
@@ -182,7 +177,7 @@ public class LambdaWebMetadataServer {
|
||||
|
||||
private static void answer(HttpServerRequest request, int status, String body) {
|
||||
HttpServerResponse response = request.response().setStatusCode(status)
|
||||
.putHeader("Date", HTTP_DATE.format(Instant.now()));
|
||||
.putHeader("Date", LambdaWebErrorPages.platformDate(Instant.now()));
|
||||
if (request.method() == HttpMethod.HEAD) {
|
||||
response.putHeader("Content-Length", String.valueOf(body.getBytes(StandardCharsets.UTF_8).length)).end();
|
||||
} else {
|
||||
|
||||
+6
@@ -46,6 +46,12 @@ class LambdaWebErrorPagesTest {
|
||||
assertEquals("Thu, 15 Oct 26 23:32:32 GMT", LambdaWebErrorPages.edgeDate(Instant.parse("2026-10-15T23:32:32Z")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformDateHasATwoDigitDay() {
|
||||
assertEquals("Sun, 01 Nov 2026 02:33:33 GMT",
|
||||
LambdaWebErrorPages.platformDate(Instant.parse("2026-11-01T02:33:33Z")));
|
||||
}
|
||||
|
||||
private static int length(LambdaWebErrorPages.Page page) {
|
||||
return LambdaWebErrorPages.html(page, REQUEST_ID).getBytes(StandardCharsets.UTF_8).length;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user