Skip to content

Commit

Permalink
test: tck test for multiple headers request (#9814)
Browse files Browse the repository at this point in the history
  • Loading branch information
driverpt authored Sep 8, 2023
1 parent 509bbd8 commit d4df928
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.micronaut.http.server.tck.tests;

import io.micronaut.context.annotation.Requires;
import io.micronaut.http.HttpHeaders;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.HttpStatus;
import io.micronaut.http.MediaType;
Expand Down Expand Up @@ -61,6 +62,21 @@ void headersAreCaseInsensitiveAsPerMessageHeadersSpecification() throws IOExcept
.build()));
}

/**
* Multiple Headers are properly received as list and not as single header
*/
@Test
void multipleHeadersAreReceivedAsList() throws IOException {
asserts(SPEC_NAME,
HttpRequest.GET("/foo/receive-multiple-headers")
.header(HttpHeaders.ETAG, "A")
.header(HttpHeaders.ETAG, "B"),
(server, request) -> AssertionUtils.assertDoesNotThrow(server, request, HttpResponseAssertion.builder()
.status(HttpStatus.OK)
.body("2")
.build()));
}

@Controller("/foo")
@Requires(property = "spec.name", value = SPEC_NAME)
static class ProduceController {
Expand All @@ -73,5 +89,10 @@ String getOkAsJson() {
String getFooAsJson(@Header("Foo") String foo, @Header("fOo") String foo2) {
return "{\"status\":\"" + foo + foo2 + "\"}";
}

@Get(value = "/receive-multiple-headers", processes = MediaType.TEXT_PLAIN)
String receiveMultipleHeaders(HttpRequest<?> request) {
return String.valueOf(request.getHeaders().getAll(HttpHeaders.ETAG).size());
}
}
}

0 comments on commit d4df928

Please sign in to comment.