mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(elbv2): preserve repeated target response headers (#5628)
This commit is contained in:
1 parent
4ea7e3da23
commit
15f50cb68e
4 files changed
+67
-11
No files matched your search
@@ -15,6 +15,7 @@ import io.github.hectorvent.floci.services.elbv2.model.TargetGroup;
|
||||
import io.github.hectorvent.floci.services.lambda.LambdaService;
|
||||
import io.github.hectorvent.floci.services.lambda.model.InvocationType;
|
||||
import io.github.hectorvent.floci.services.lambda.model.InvokeResult;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.buffer.Buffer;
|
||||
import io.vertx.core.http.HttpClient;
|
||||
@@ -23,6 +24,7 @@ import io.vertx.core.http.HttpMethod;
|
||||
import io.vertx.core.http.HttpServer;
|
||||
import io.vertx.core.http.HttpServerOptions;
|
||||
import io.vertx.core.http.HttpServerRequest;
|
||||
import io.vertx.core.http.HttpServerResponse;
|
||||
import io.vertx.core.http.HttpVersion;
|
||||
import io.vertx.core.http.RequestOptions;
|
||||
import io.vertx.core.net.NetSocket;
|
||||
@@ -39,6 +41,7 @@ import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -738,11 +741,7 @@ public class ElbV2DataPlane {
|
||||
}
|
||||
responseStarted.set(true);
|
||||
req.response().setStatusCode(resp.statusCode());
|
||||
resp.headers().forEach(entry -> {
|
||||
if (!HOP_BY_HOP_HEADERS.contains(entry.getKey().toLowerCase())) {
|
||||
req.response().putHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
});
|
||||
copyTargetResponseHeaders(resp.headers(), req.response());
|
||||
if (resp.getHeader("Content-Length") == null) {
|
||||
req.response().setChunked(true);
|
||||
}
|
||||
@@ -775,6 +774,14 @@ public class ElbV2DataPlane {
|
||||
});
|
||||
}
|
||||
|
||||
private static void copyTargetResponseHeaders(MultiMap headers, HttpServerResponse response) {
|
||||
for (String name : headers.names()) {
|
||||
if (!HOP_BY_HOP_HEADERS.contains(name.toLowerCase(Locale.ROOT))) {
|
||||
response.putHeader(name, headers.getAll(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An ALB forwards a WebSocket handshake to an instance or ip target with its upgrade headers
|
||||
* intact, which an ordinary proxied request cannot do: {@code Connection} and {@code Upgrade}
|
||||
@@ -842,11 +849,7 @@ public class ElbV2DataPlane {
|
||||
clientReq.connect()
|
||||
.onSuccess(resp -> {
|
||||
req.response().setStatusCode(resp.statusCode());
|
||||
resp.headers().forEach(entry -> {
|
||||
if (!HOP_BY_HOP_HEADERS.contains(entry.getKey().toLowerCase())) {
|
||||
req.response().putHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
});
|
||||
copyTargetResponseHeaders(resp.headers(), req.response());
|
||||
if (resp.statusCode() != 101) {
|
||||
req.resume();
|
||||
if (resp.getHeader("Content-Length") == null) {
|
||||
|
||||
Reference in new issue
Block a user