1
1
package com .amazonaws .services .lambda .runtime .events ;
2
2
3
3
import java .io .Serializable ;
4
- import java .util .List ;
5
- import java .util .Map ;
4
+ import java .util .*;
6
5
7
6
/**
8
7
* Class that represents an APIGatewayProxyRequestEvent
@@ -17,9 +16,9 @@ public class APIGatewayProxyRequestEvent implements Serializable, Cloneable {
17
16
18
17
private String httpMethod ;
19
18
20
- private Map <String , String > headers ;
19
+ private Headers <String > headers = new Headers <>() ;
21
20
22
- private Map < String , List <String >> multiValueHeaders ;
21
+ private Headers < List <String >> multiValueHeaders = new Headers <>() ;
23
22
24
23
private Map <String , String > queryStringParameters ;
25
24
@@ -35,6 +34,77 @@ public class APIGatewayProxyRequestEvent implements Serializable, Cloneable {
35
34
36
35
private Boolean isBase64Encoded ;
37
36
37
+ /**
38
+ * Class that represents Http Headers.
39
+ *
40
+ * Not using a standard map, because we need insensitive case.
41
+ */
42
+ public static class Headers <T > implements Map <String , T > {
43
+
44
+ // Headers are case insensitive (https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2)
45
+ private Map <String , T > map = new TreeMap <>(String .CASE_INSENSITIVE_ORDER );
46
+
47
+ @ Override
48
+ public int size () {
49
+ return map .size ();
50
+ }
51
+
52
+ @ Override
53
+ public boolean isEmpty () {
54
+ return map .isEmpty ();
55
+ }
56
+
57
+ @ Override
58
+ public boolean containsKey (Object key ) {
59
+ return map .containsKey (key );
60
+ }
61
+
62
+ @ Override
63
+ public boolean containsValue (Object value ) {
64
+ return map .containsValue (value );
65
+ }
66
+
67
+ @ Override
68
+ public T get (Object key ) {
69
+ return map .get (key );
70
+ }
71
+
72
+ @ Override
73
+ public T put (String key , T value ) {
74
+ return map .put (key , value );
75
+ }
76
+
77
+ @ Override
78
+ public T remove (Object key ) {
79
+ return map .remove (key );
80
+ }
81
+
82
+ @ Override
83
+ public void putAll (Map <? extends String , ? extends T > m ) {
84
+ map .putAll (m );
85
+ }
86
+
87
+ @ Override
88
+ public void clear () {
89
+ map .clear ();
90
+ }
91
+
92
+ @ Override
93
+ public Set <String > keySet () {
94
+ return map .keySet ();
95
+ }
96
+
97
+ @ Override
98
+ public Collection <T > values () {
99
+ return map .values ();
100
+ }
101
+
102
+ @ Override
103
+ public Set <Entry <String , T >> entrySet () {
104
+ return map .entrySet ();
105
+ }
106
+ }
107
+
38
108
/**
39
109
* class that represents proxy request context
40
110
*/
@@ -67,7 +137,8 @@ public static class ProxyRequestContext implements Serializable, Cloneable {
67
137
/**
68
138
* default constructor
69
139
*/
70
- public ProxyRequestContext () {}
140
+ public ProxyRequestContext () {
141
+ }
71
142
72
143
/**
73
144
* @return account id that owns Lambda function
@@ -101,7 +172,7 @@ public void setAuthorizer(final Map<String, Object> authorizer) {
101
172
}
102
173
103
174
/**
104
- * @return API Gateway stage name
175
+ * @return API Gateway stage name
105
176
*/
106
177
public String getStage () {
107
178
return stage ;
@@ -286,14 +357,14 @@ public ProxyRequestContext withPath(String path) {
286
357
287
358
/**
288
359
* @return The name of the operation being performed
289
- * * /
360
+ */
290
361
public String getOperationName () {
291
362
return operationName ;
292
363
}
293
364
294
365
/**
295
366
* @param operationName The name of the operation being performed
296
- * * /
367
+ */
297
368
public void setOperationName (String operationName ) {
298
369
this .operationName = operationName ;
299
370
}
@@ -307,7 +378,6 @@ public ProxyRequestContext withOperationName(String operationName) {
307
378
* Returns a string representation of this object; useful for testing and debugging.
308
379
*
309
380
* @return A string representation of this object.
310
- *
311
381
* @see Object#toString()
312
382
*/
313
383
@ Override
@@ -412,7 +482,7 @@ public int hashCode() {
412
482
hashCode = prime * hashCode + ((getApiId () == null ) ? 0 : getApiId ().hashCode ());
413
483
hashCode = prime * hashCode + ((getPath () == null ) ? 0 : getPath ().hashCode ());
414
484
hashCode = prime * hashCode + ((getAuthorizer () == null ) ? 0 : getAuthorizer ().hashCode ());
415
- hashCode = prime * hashCode + ((getOperationName () == null ) ? 0 : getOperationName ().hashCode ());
485
+ hashCode = prime * hashCode + ((getOperationName () == null ) ? 0 : getOperationName ().hashCode ());
416
486
return hashCode ;
417
487
}
418
488
@@ -457,7 +527,8 @@ public static class RequestIdentity implements Serializable, Cloneable {
457
527
/**
458
528
* default constructor
459
529
*/
460
- public RequestIdentity () {}
530
+ public RequestIdentity () {
531
+ }
461
532
462
533
/**
463
534
* @return The Cognito identity pool id.
@@ -739,7 +810,6 @@ public RequestIdentity withAccessKey(String accessKey) {
739
810
* Returns a string representation of this object; useful for testing and debugging.
740
811
*
741
812
* @return A string representation of this object.
742
- *
743
813
* @see Object#toString()
744
814
*/
745
815
@ Override
@@ -869,7 +939,8 @@ public RequestIdentity clone() {
869
939
/**
870
940
* default constructor
871
941
*/
872
- public APIGatewayProxyRequestEvent () {}
942
+ public APIGatewayProxyRequestEvent () {
943
+ }
873
944
874
945
/**
875
946
* @return The resource path defined in API Gateway
@@ -944,14 +1015,14 @@ public APIGatewayProxyRequestEvent withHttpMethod(String httpMethod) {
944
1015
* @return The headers sent with the request
945
1016
*/
946
1017
public Map <String , String > getHeaders () {
947
- return headers ;
1018
+ return headers . map ;
948
1019
}
949
1020
950
1021
/**
951
1022
* @param headers The headers sent with the request
952
1023
*/
953
1024
public void setHeaders (Map <String , String > headers ) {
954
- this .headers = headers ;
1025
+ this .headers . putAll ( headers ) ;
955
1026
}
956
1027
957
1028
/**
@@ -974,7 +1045,7 @@ public Map<String, List<String>> getMultiValueHeaders() {
974
1045
* @param multiValueHeaders The multi value headers sent with the request
975
1046
*/
976
1047
public void setMultiValueHeaders (Map <String , List <String >> multiValueHeaders ) {
977
- this .multiValueHeaders = multiValueHeaders ;
1048
+ this .multiValueHeaders . putAll ( multiValueHeaders ) ;
978
1049
}
979
1050
980
1051
/**
@@ -1167,7 +1238,6 @@ public APIGatewayProxyRequestEvent withIsBase64Encoded(Boolean isBase64Encoded)
1167
1238
* Returns a string representation of this object; useful for testing and debugging.
1168
1239
*
1169
1240
* @return A string representation of this object.
1170
- *
1171
1241
* @see Object#toString()
1172
1242
*/
1173
1243
@ Override
0 commit comments