Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore Transfer-Encoding for lambda/azf #33836

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ public void handleMessage(Object msg) {
}
final StringBuilder sb = new StringBuilder();
for (Iterator<String> valueIterator = allForName.iterator(); valueIterator.hasNext();) {
sb.append(valueIterator.next());
String val = valueIterator.next();
if (name.equalsIgnoreCase("Transfer-Encoding")
&& val.equals("chunked")) {
continue; // ignore transfer encoding, chunked screws up message and response
}
sb.append(val);
if (valueIterator.hasNext()) {
sb.append(",");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ public void handleMessage(Object msg) {
}
responseBuilder.setMultiValueHeaders(new Headers());
for (String name : res.headers().names()) {
if (name.equalsIgnoreCase("Transfer-Encoding")) {
continue; // ignore transfer encoding, chunked screws up message and response
}
for (String v : res.headers().getAll(name)) {
if (name.equalsIgnoreCase("Transfer-Encoding") && v.contains("chunked")) {
continue;
}
responseBuilder.getMultiValueHeaders().add(name, v);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
import io.quarkus.amazon.lambda.runtime.AmazonLambdaApi;
import io.quarkus.amazon.lambda.runtime.LambdaHotReplacementRecorder;
import io.quarkus.amazon.lambda.runtime.MockEventServer;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.Produce;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem;
import io.quarkus.deployment.builditem.DevServicesResultBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.RuntimeApplicationShutdownBuildItem;
import io.quarkus.deployment.builditem.ServiceStartBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.runtime.LaunchMode;

public class DevServicesLambdaProcessor {
Expand Down Expand Up @@ -53,12 +53,12 @@ private boolean legacyTestingEnabled() {
}

@Produce(ServiceStartBuildItem.class)
@BuildStep(onlyIfNot = IsNormal.class)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public void startEventServer(LaunchModeBuildItem launchMode,
LambdaConfig config,
Optional<EventServerOverrideBuildItem> override,
BuildProducer<DevServicesResultBuildItem> devServicePropertiesProducer,
BuildProducer<RuntimeApplicationShutdownBuildItem> runtimeApplicationShutdownBuildItemBuildProducer)
CuratedApplicationShutdownBuildItem closeBuildItem)
throws Exception {
if (!launchMode.getLaunchMode().isDevOrTest())
return;
Expand Down Expand Up @@ -106,10 +106,6 @@ public void startEventServer(LaunchModeBuildItem launchMode,
startMode = null;
server = null;
};
QuarkusClassLoader cl = (QuarkusClassLoader) Thread.currentThread().getContextClassLoader();
((QuarkusClassLoader) cl.parent()).addCloseTask(closeTask);
if (launchMode.isTest()) {
runtimeApplicationShutdownBuildItemBuildProducer.produce(new RuntimeApplicationShutdownBuildItem(closeTask));
}
closeBuildItem.addCloseTask(closeTask, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public void handleMessage(Object msg) {
HttpResponse res = (HttpResponse) msg;
responseBuilder = request.createResponseBuilder(HttpStatus.valueOf(res.status().code()));
for (Map.Entry<String, String> entry : res.headers()) {
if (entry.getKey().equalsIgnoreCase("Transfer-Encoding")
&& entry.getValue().contains("chunked")) {
continue; // ignore transfer encoding, chunked screws up message and response
}
//log.info("header(" + entry.getKey() + ")=" + entry.getValue());
responseBuilder.header(entry.getKey(), entry.getValue());
}
}
Expand Down