Use case-insensitive comparator in HttpHeadersAssert

Closes gh-36349
This commit is contained in:
rstoyanchev
2026-02-20 13:38:51 +00:00
parent d4b2a493f9
commit b9a59853fa
3 changed files with 6 additions and 6 deletions
@@ -47,7 +47,9 @@ public class HttpHeadersAssert extends AbstractObjectAssert<HttpHeadersAssert, H
public HttpHeadersAssert(HttpHeaders actual) {
super(actual, HttpHeadersAssert.class);
as("HTTP headers");
// Use case-insensitive comparator until https://github.com/assertj/assertj/issues/4157
this.namesAssert = Assertions.assertThat(actual.headerNames())
.usingElementComparator(String.CASE_INSENSITIVE_ORDER)
.as("HTTP header names");
}
@@ -31,8 +31,6 @@ import org.springframework.http.HttpStatus.Series;
import org.springframework.http.MediaType;
import org.springframework.test.http.HttpHeadersAssert;
import org.springframework.test.http.MediaTypeAssert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.function.SingletonSupplier;
/**
@@ -65,9 +63,9 @@ public abstract class AbstractHttpServletResponseAssert<R extends HttpServletRes
}
private static HttpHeaders getHttpHeaders(HttpServletResponse response) {
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
HttpHeaders headers = new HttpHeaders();
response.getHeaderNames().forEach(name -> headers.put(name, new ArrayList<>(response.getHeaders(name))));
return new HttpHeaders(headers);
return headers;
}
/**