-
Notifications
You must be signed in to change notification settings - Fork 83
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
fix: Populate AWSProxyResponse headers with multi #1338
base: 5.0.x
Are you sure you want to change the base?
Conversation
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
|
||
private static Map<String, String> getHeaders(AwsProxyResponse awsProxyResponse) { | ||
Headers multiValueHeaders = awsProxyResponse.getMultiValueHeaders(); | ||
Map<String, String> headers = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a linked hash map to retain order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved via 0f624cb
Map<String, String> headers = new HashMap<>(); | ||
for (Map.Entry<String, List<String>> entry : multiValueHeaders.entrySet()) { | ||
List<String> headerValues = entry.getValue(); | ||
if (headerValues != null && headerValues.size() == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use iterator.hasNext()
and iterator.next()
instead of calling size()
and get(0)
which is less efficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check: No headers will be added if the size > 1
, is this intended?
suggestion: Try this instead headerValues.stream().first().ifPresent(value -> headers.put(entry.getKey(), value));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved via 52b852e
...ion-aws-api-proxy/src/main/java/io/micronaut/function/aws/proxy/MicronautResponseWriter.java
Outdated
Show resolved
Hide resolved
…/proxy/MicronautResponseWriter.java Co-authored-by: Thobias Karlsson <[email protected]>
Fixes: #1330