From 5ebe4d3973228979b936bb412b28fed747511b29 Mon Sep 17 00:00:00 2001 From: Richard Thomas Date: Fri, 26 Mar 2021 19:07:01 +0100 Subject: [PATCH] Copy value of Content-Type from Netty response headers to AWS response builder --- .../amazon/lambda/http/LambdaHttpHandler.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java b/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java index fa99269e88ee1..93b1ef4d9c5e7 100644 --- a/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java +++ b/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java @@ -6,6 +6,7 @@ import java.nio.channels.WritableByteChannel; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -25,6 +26,7 @@ import io.netty.handler.codec.http.DefaultLastHttpContent; import io.netty.handler.codec.http.HttpContent; import io.netty.handler.codec.http.HttpHeaderNames; +import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpResponse; import io.netty.handler.codec.http.HttpVersion; @@ -92,6 +94,16 @@ public void handleMessage(Object msg) { HttpResponse res = (HttpResponse) msg; responseBuilder.setStatusCode(res.status().code()); + final HttpHeaders responseHeaders = res.headers(); + if (responseHeaders != null) { + final String contentType = responseHeaders.getAsString(HttpHeaderNames.CONTENT_TYPE); + if (contentType != null && contentType.trim().length() > 0) { + final Map headers = new HashMap<>(); + headers.put("Content-Type", contentType); + responseBuilder.setHeaders(headers); + } + } + Headers multiValueHeaders = new Headers(); responseBuilder.setMultiValueHeaders(multiValueHeaders); for (String name : res.headers().names()) {