mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
feat(lambda-web): add a text/plain Content-Type to app responses that send none (#7285)
This commit is contained in:
1 parent
cf582c21be
commit
f1c7098d9c
3 files changed
+31
-10
No files matched your search
+11
-3
@@ -590,7 +590,11 @@ public class LambdaWebDataPlane {
|
||||
headers.set("Connection", "close");
|
||||
}
|
||||
|
||||
/** The platform writes its own {@code Date} in place of the app's, but lets a {@code date} in lowercase pass. */
|
||||
/**
|
||||
* The platform writes its own {@code Date} in place of the app's, but lets a {@code date} in lowercase pass. It
|
||||
* writes {@code text/plain} for an app that sends no {@code Content-Type}, even on a 204 or a HEAD, but not with a
|
||||
* {@code Content-Length} of 0.
|
||||
*/
|
||||
static void copyResponseHeaders(MultiMap headers, HttpServerResponse out) {
|
||||
out.headers().add("Date", LambdaWebErrorPages.platformDate(Instant.now()));
|
||||
Set<String> dropped = new HashSet<>(DROPPED_RESPONSE_HEADERS);
|
||||
@@ -600,10 +604,14 @@ public class LambdaWebDataPlane {
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, String> header : headers) {
|
||||
if (!"Date".equals(header.getKey()) && !dropped.contains(header.getKey().toLowerCase(Locale.ROOT))) {
|
||||
out.headers().add(header.getKey(), header.getValue());
|
||||
String name = header.getKey();
|
||||
if (!"Date".equals(name) && !dropped.contains(name.toLowerCase(Locale.ROOT))) {
|
||||
out.headers().add("Content-Type".equalsIgnoreCase(name) ? "Content-Type" : name, header.getValue());
|
||||
}
|
||||
}
|
||||
if (!headers.contains("Content-Type") && !"0".equals(headers.get("Content-Length"))) {
|
||||
out.headers().add("Content-Type", "text/plain; charset=utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
static int port(String host, String scheme) {
|
||||
|
||||
Reference in new issue
Block a user