Skip to content
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

test: tck test for multiple headers request #9814

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
}