Skip to content

Commit f3e80cc

Browse files
committed
corrections after real test
1 parent 28333c0 commit f3e80cc

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2HTTPEvent.java

+13
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ public class APIGatewayV2HTTPEvent {
4343
private boolean isBase64Encoded;
4444
private RequestContext requestContext;
4545

46+
public void setHeaders(Map<String, String> headers) {
47+
System.out.println("setHeaders");
48+
if (headers == null || headers.isEmpty()) {
49+
this.headers = null;
50+
return;
51+
}
52+
53+
if (this.headers == null) {
54+
this.headers = new HttpHeaders<>();
55+
}
56+
this.headers.putAll(headers);
57+
}
58+
4659
@AllArgsConstructor
4760
@Builder(setterPrefix = "with")
4861
@Data

aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2HTTPResponse.java

+35
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,39 @@ public class APIGatewayV2HTTPResponse {
3333
private List<String> cookies;
3434
private String body;
3535
private boolean isBase64Encoded;
36+
37+
public static APIGatewayV2HTTPResponseBuilder builder() {
38+
return new APIGatewayV2HTTPResponseBuilder();
39+
}
40+
41+
public static class APIGatewayV2HTTPResponseBuilder {
42+
private HttpHeaders<String> headers;
43+
private HttpHeaders<List<String>> multiValueHeaders;
44+
45+
public APIGatewayV2HTTPResponseBuilder withHeaders(Map<String, String> headers) {
46+
if (headers == null || headers.isEmpty()) {
47+
this.headers = null;
48+
return this;
49+
}
50+
51+
if (this.headers == null) {
52+
this.headers = new HttpHeaders<>();
53+
}
54+
this.headers.putAll(headers);
55+
return this;
56+
}
57+
58+
public APIGatewayV2HTTPResponseBuilder withMultiValueHeaders(Map<String, List<String>> multiValueHeaders) {
59+
if (multiValueHeaders == null || multiValueHeaders.isEmpty()) {
60+
this.multiValueHeaders = null;
61+
return this;
62+
}
63+
64+
if (this.multiValueHeaders == null) {
65+
this.multiValueHeaders = new HttpHeaders<>();
66+
}
67+
this.multiValueHeaders.putAll(multiValueHeaders);
68+
return this;
69+
}
70+
}
3671
}

aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/HttpHeaders.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class HttpHeaders<T> implements Map<String, T> {
1414

1515
// Headers are case insensitive (https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2)
16-
private Map<String, T> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
16+
private final Map<String, T> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
1717

1818
@Override
1919
public int size() {

0 commit comments

Comments
 (0)