Skip to content

Commit ad832b1

Browse files
sapessijogep
authored andcommitted
fix: Use single value headers for HTTP API response (aws#377)
Parametrized the use of the single value headers for the response writer to support the v2 proxy schema for HTTP API
1 parent b14aa73 commit ad832b1

File tree

1 file changed

+15
-2
lines changed
  • aws-serverless-java-container-springboot2/src/test/java/com/amazonaws/serverless/proxy/spring

1 file changed

+15
-2
lines changed

aws-serverless-java-container-springboot2/src/test/java/com/amazonaws/serverless/proxy/spring/ServletAppTest.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
import java.util.Collection;
2424
import java.util.stream.Collectors;
2525

26-
import static org.junit.Assert.assertEquals;
27-
import static org.junit.Assert.assertNotNull;
26+
import static org.junit.Assert.*;
2827

2928
@RunWith(Parameterized.class)
3029
public class ServletAppTest {
@@ -192,4 +191,18 @@ public void springExceptionMapping_throw404Ex_expectMappedTo404() {
192191
assertNotNull(resp);
193192
assertEquals(404, resp.getStatusCode());
194193
}
194+
195+
@Test
196+
public void echoMessage_populatesSingleValueHeadersForHttpApiV2() {
197+
AwsProxyRequestBuilder req = new AwsProxyRequestBuilder("/message", "POST")
198+
.header(HttpHeaders.CONTENT_TYPE, "application/json;v=1")
199+
.header(HttpHeaders.ACCEPT, "application/json;v=1")
200+
.body(new MessageData("test message"));
201+
AwsProxyResponse resp = handler.handleRequest(req, lambdaContext);
202+
if ("HTTP_API".equals(type)) {
203+
assertNotNull(resp.getHeaders());
204+
} else {
205+
assertNull(resp.getHeaders());
206+
}
207+
}
195208
}

0 commit comments

Comments
 (0)